Next uses invalid URL behind proxy
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
https://github.com/apfelbox/reproducer-invalid-next-host
To Reproduce
- Run
pnpm dev - Open http://localhost:3000
- Open the same URL via a reverse proxy.
Current vs. Expected behavior
The internal URL (in request.url and request.nextUrl) should use the correct and proper URL, as otherwise we can't use it for anything output related. We can't just generate an URL, as it will be generated with localhost:3000.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000
Binaries:
Node: 18.19.0
npm: 10.2.3
Yarn: N/A
pnpm: 8.15.5
Relevant Packages:
next: 14.1.3
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: 5.4.2
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local)
Additional context
No response
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 with the linked reproducer and run pnpm dev, checking request.url and request.nextUrl both directly and through a reverse proxy. Trace how the App Router constructs these URLs in next dev and next start. Done means both values use the proper proxied URL instead of localhost:3000.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nextjs
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100