[🐞] V1 build.assetsDir causes public files to not work
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 22.1k
- Forks
- 1.4k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
Which component is affected?
Qwik City (routing)
Describe the bug
We're sharing a domain with our old angular app and the new qwik one and setting build.assetsDIr to "q" allows us to whitelist an entire directory in the load balancer to go to qwik to serve it.
With this set, I'm noticing that various files within our public directory aren't being handled as a static file, like robots.txt or manifest.json. A quick fix could be to move manifest.json into /q/ post build but Google expects robots.txt to be served from the root, so I need to fix it.
After building and serving our node entrypoint, I'm noticing that there's a isStaticFile check, which has a generated array of staticFiles that were detected during build. These have doubled up /q/q/ paths but everything still works because of the cheap /q/build check beforehand. Example:
I've looked around and it seems that the pathname is being prefixed with assetsDir here: https://github.com/QwikDev/qwik/blame/38429a16069f5cf03986cb82f636d78680fdf389/packages/qwik-city/src/adapters/shared/vite/index.ts#L172
Removing this prefixing of assetDir seems to fix it for us, proof (with the assetsDir correctly added to the build JS files):
The git blame says this was added by @gioboa via https://github.com/QwikDev/qwik/pull/6588 1 year ago.
Removing this prefixing of assetsDir works both with/without a build.assetsDir being set for me but I don't want to regress whatever it was added for. Can you confirm that removing that line is ok @gioboa? I'll do a PR and patch it locally so I can move forward.
Contributor guide
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 in packages/qwik-city/src/adapters/shared/vite/index.ts around the pathname prefixing described in the issue, then trace how the generated staticFiles array is used by the node entrypoint. Confirm that public files such as robots.txt and manifest.json work with and without build.assetsDir, while assets under the configured directory continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vite
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100