Consecutive slashes in URL trigger routing error and no page renders in browser when Next.js runs behind gateway
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/cosieLq/exampleApp_nextjs/tree/reproduction-double-slash-routing-error
To Reproduce
- Start the application (npm run dev or npm run start)
- Start the gateway (node proxy.js)
- Go to localhost:8000///about
- Observe browser console and see 'Error: invariant: invalid relative URL, router received...'
Current vs. Expected behavior
I expected no error in browser console and the page to render correctly.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.6.0: Wed Jul 31 20:48:52 PDT 2024; root:xnu-10063.141.1.700.5~1/RELEASE_ARM64_T6020
Available memory (MB): 16384
Available CPU cores: 12
Binaries:
Node: 20.15.1
npm: 10.7.0
Yarn: 1.22.19
pnpm: N/A
Relevant Packages:
next: 15.0.0-canary.179 // Latest available version is detected (15.0.0-canary.179).
eslint-config-next: N/A
react: 19.0.0-beta-04b058868c-20240508
react-dom: 19.0.0-beta-04b058868c-20240508
typescript: 5.1.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Internationalization (i18n), Navigation, Pages Router
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local), Other (Deployed)
Additional context
When i18n is disabled in next.config.js, no error will appear and the page renders correctly.
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 exampleApp_nextjs reproduction branch, run npm run dev or npm run start alongside node proxy.js, and reproduce the issue at localhost:8000///about. Then compare the behavior with i18n enabled and disabled in next.config.js, tracing the Pages Router navigation path. Done means the browser console has no routing error and the page renders correctly behind the gateway.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nextjs, node.js, react
- Domain
- frontend, internationalization, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100