Skip to content

Commit

Permalink
Fix redirect url for prefixing the default locale (#33762)
Browse files Browse the repository at this point in the history
We want to prefix the default locale to the current path (`/path`), not the current href (`http://domain.tld/path`).


## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
  • Loading branch information
lancechentw and ijjk committed Feb 6, 2022
1 parent 6890e3f commit 93fa129
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/advanced-features/i18n-routing.md
Expand Up @@ -183,7 +183,9 @@ export function middleware(request: NextRequest) {

return shouldHandleLocale
? NextResponse.redirect(
`/en${stripDefaultLocale(request.nextUrl.pathname)}`
`/en${stripDefaultLocale(request.nextUrl.pathname)}${
request.nextUrl.search
}`
)
: undefined
}
Expand Down

0 comments on commit 93fa129

Please sign in to comment.