NextCustomServer overwrites req.url with internal NextJS path
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue or a replay of the bug
https://github.com/tills13/nextjs-req-url-reproduction
To Reproduce
- install deps (
npm ci) - build next (
npx next build) - run server (
node server.js) - navigate to
http://localhost:3000(any path) - note that the URL is the internal NextJS URL instead of the expected user-facing URL
Current vs. Expected behavior
The expected behaviour is that, for Custom Servers, at least, the request URL is untouched as you might want to render a page at a different path than what the URL path is e.g. /blog/some-slug/ -> /pages/blog_post.js
Our sites do not have uniform URLs (both /blog/some-slug/ and /some-slug/ might refer to a blog post or a static page and we don't know until we resolve the object from our CMS) so we cannot use file system routing.
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023
Binaries:
Node: 16.20.0
npm: 8.19.4
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 13.4.20-canary.27
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: N/A
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Routing (next/router, next/navigation, next/link)
Additional context
Seems like the issue was introduce in https://github.com/vercel/next.js/pull/49805 or https://github.com/vercel/next.js/pull/53523
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
Use the linked reproduction repository and follow its npm ci, npx next build, and node server.js steps. Start with server.js and the custom-server request path, then verify that navigating to any path leaves req.url as the user-facing URL rather than an internal Next.js path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, next.js, node.js
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100