-
Notifications
You must be signed in to change notification settings - Fork 27k
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
404 if public/ filename contains a space #10004
Comments
Only until filenames with spaces in them are supported by the nextjs dev server: vercel/next.js#10004
Related #9706 |
Prior to this pull request, Next.js would immediately decode all URLs sent to its server (via `path-match`). This was rarely needed, and Next.js would typically re-encode the incoming request right away (see all the `encodeURIComponent`s removed in PR diff). This adds unnecessary performance overhead. Long term, this will also help prevent weird encoding edge-cases like #10004, #10022, #11371, et al. --- No new tests are necessary for this change because we've extensively tested these edge cases with existing tests. One test was updated to reflect that we skip decoding in a 404 scenario. Let's see if all the existing tests pass!
Prior to this pull request, Next.js would immediately decode all URLs sent to its server (via `path-match`). This was rarely needed, and Next.js would typically re-encode the incoming request right away (see all the `encodeURIComponent`s removed in PR diff). This adds unnecessary performance overhead. Long term, this will also help prevent weird encoding edge-cases like vercel#10004, vercel#10022, vercel#11371, et al. --- No new tests are necessary for this change because we've extensively tested these edge cases with existing tests. One test was updated to reflect that we skip decoding in a 404 scenario. Let's see if all the existing tests pass!
Not sure if we're doing anything wrong, but we're still getting this bug - we have an asset under |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
Static assets served from public/ result in 404 if they contain a space character.
Also true if the filename contains
%20
rather than a space literal.To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
mkdir test
cd test
npm init -y
npm install --save next react react-dom
mkdir pages public
echo "Foo" > public/hello.txt
echo "Foo" > public/hello\ world.txt
npx next
Expected behavior
curl http://localhost:3000/hello.txt
→ Foocurl http://localhost:3000/hello\ world.txt
→ Foocurl http://localhost:3000/hello%20world.txt
→ FooActual behavior
curl http://localhost:3000/hello.txt
→ Foocurl http://localhost:3000/hello\ world.txt
→ 404curl http://localhost:3000/hello%20world.txt
→ 404Screenshots
System information
Additional context
Does't happen when serving from the deprecated static/ directory.
Have only tried with the next local dev server.
The text was updated successfully, but these errors were encountered: