`createIPXWebServer` seems to have trouble with Hono basePaths
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.5k
- Forks
- 93
- PR merge metrics
- No merged PRs in 30d
Description
Environment
node@22.4.1ipx@3.0.1hono@4.5.2
Reproduction
import { Hono } from "hono";
import { cors } from "hono/cors";
import { logger } from "hono/logger";
import {
createIPX,
createIPXWebServer,
ipxFSStorage,
ipxHttpStorage,
} from "ipx";
const ipx = createIPX({
storage: ipxFSStorage({
dir: "./public",
}),
httpStorage: ipxHttpStorage({
allowAllDomains: true,
}),
});
const app = new Hono().basePath("/worker/v1")
app.use(logger());
app.use(cors());
app.use("/*", (c) => createIPXWebServer(ipx)(c.req.raw));
export default {
port: process.env.PORT ?? 8080,
fetch: app.fetch,
};
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:
{
"error": {
"message": "[404] [IPX_FILE_NOT_FOUND] File not found: /v1/grayscale/butt.png"
}
}
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:
const app = new Hono() // No basePath
app.use("/img/*", (c) => createIPXWebServer(ipx)(c.req.raw)); // However, with a path segment defined here
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the createIPXWebServer entry point and reproduce the two cases shown: a Hono basePath and an app.use path segment. Trace how the request URL is passed to IPX, then verify that operations and source paths resolve correctly for both /worker/v1/grayscale/butt.png and /img/grayscale/butt.png.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100