Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(docs): update i18n-routing.md (#33123)
The recommended code for `_middleware.ts` does not work in prod, but does work locally. You need to use `request.nextUrl.pathname` to properly redirect from what I can tell. You also need to have a quick helper function to strip off the `/default` locale at the start of the pathname as we are providing `/en` as a fallback locale. FWIW - I am pretty new to NextJS. Someone with more experience should probably review this suggestion before merging it. What I can tell you however is that the code as it is in `_middleware.ts` works locally but breaks in prod. To test this out use the code and navigate to `https//www.mysite.com` - it will work as expected on the root url, as this matches `nextUrl.href`. Now try navigating to `https//www.mysite.com/about` and you will be redirected to `https://www.mysite.com/en/https://www.mysite.com/about`. ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` Closes: #33762 Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
- Loading branch information