-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createIPXWebServer
seems to have trouble with Hono basePaths
#239
Labels
Comments
I was able to get it to work finally with a bit of a hacky workaround. Even without defining a What I ended up doing was stripping out the "base path" from the const img = new Hono()
img.use("/img/*", c => createIPXWebServer(ipx)(new Request(c.req.raw.url.replace(/\/img/, ""))))
const app = new Hono()
app.route('/', img)
const BASE_PATH = "/worker/v1"
app.route(`${BASE_PATH}/bookmark`, bookmark)
app.route(`${BASE_PATH}/feed`, feed) |
Hey @ndom91 noticed the same thing, and my solution is export const app = createApp().use("/optimize", createIPXH3Handler(ipx));
const handler = toWebHandler(app); and then detect if it's // Bun's fetch, but should work for whatever
Bun.serve({
port: 3000,
async fetch(req) {
let url = new URL(req.url);
if (url.pathname.startsWith("/optimize")) {
return handler(req);
}
return honoApp.fetch(req);
}
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
node@22.4.1
ipx@3.0.1
hono@4.5.2
Reproduction
Describe the bug
As you can see in the example above, I'm using a basepath of
/worker/v1
.When attempting to visit the following URL:
http://localhost:8000/worker/v1/grayscale/butt.png
I get the following error:
However, if I remove the basePath option on the Hono instantiation everythign does work. For example, then when visiting
http://localhost:8000/grayscale/butt.png
I get a grayscale version of the image.In addition, passing a path section to the
app.use()
call doesn't seem to work as expected either. So for example, a Hono instance setup like this:Throws the same "File not found" error when visitng, for example:
http://localhost:8000/img/grayscale/butt.png
Oddly,
http://localhost:8000/img/butt.png
does load the raw original image then, but I can't apply any operations via a path segment.Additional context
Maybe I'm missing something, but it seems that my usage of the basePath / path sections should work, no?
Logs
No response
The text was updated successfully, but these errors were encountered: