basepath on NextRequest.nextUrl not set consistent when using basePath and i18n
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.5k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Home
Binaries:
Node: 18.15.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.4.3-canary.1
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: 4.9.5
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Internationalization (i18n)
Link to the code that reproduces this issue
https://github.com/paulvanbrenk/basepath-bug-nextjs
To Reproduce
Clone repo
Run npm run dev
navigate to http://localhost:3000/home/fr
Notice output in terminal has an empty basePath.
Compare this to the output when navigating to http://localhost:3000/home/en
Describe the Bug
The basePath in NextRequest.nextUrl in the middleware is not set as expected for any locale that's not the default locale.
See the output from the console.log in the repro.
Expected Behavior
The basePath to be set consistent in dependent of the locale used.
Which browser are you using? (if relevant)
n/a
How are you deploying your application? (if relevant)
n/a
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 reproduction repository, run npm run dev, and inspect the middleware console output while visiting /home/fr and /home/en. Done means NextRequest.nextUrl.basePath is set consistently for the default and non-default locales.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nextjs, react
- Domain
- internationalization, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100