Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(docs): update i18n-routing.md #33123

Merged
merged 3 commits into from Feb 6, 2022
Merged

(docs): update i18n-routing.md #33123

merged 3 commits into from Feb 6, 2022

Commits on Jan 10, 2022

  1. Update i18n-routing.md

    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`.
    ehowey committed Jan 10, 2022
    Configuration menu
    Copy the full SHA
    b6ac076 View commit details
    Browse the repository at this point in the history

Commits on Feb 6, 2022

  1. Configuration menu
    Copy the full SHA
    beb474e View commit details
    Browse the repository at this point in the history
  2. lint-fix

    ijjk committed Feb 6, 2022
    Configuration menu
    Copy the full SHA
    f7883e5 View commit details
    Browse the repository at this point in the history