-
Notifications
You must be signed in to change notification settings - Fork 86
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
fix: handle middleware redirects to default locale and same path #2636
Merged
pieh
merged 3 commits into
main
from
michalpiechowiak/frb-1363-nextjs-i18n-middleware-redirect-not-working
Oct 1, 2024
Merged
fix: handle middleware redirects to default locale and same path #2636
pieh
merged 3 commits into
main
from
michalpiechowiak/frb-1363-nextjs-i18n-middleware-redirect-not-working
Oct 1, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
📊 Package size report -0%↓
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
pieh
added
the
test all versions
Run e2e tests against old and canary versions of Next.js
label
Oct 1, 2024
…g locale to defalt
pieh
force-pushed
the
michalpiechowiak/frb-1363-nextjs-i18n-middleware-redirect-not-working
branch
from
October 1, 2024 07:31
88fc614
to
5d7c353
Compare
pieh
force-pushed
the
michalpiechowiak/frb-1363-nextjs-i18n-middleware-redirect-not-working
branch
from
October 1, 2024 09:04
b075038
to
f9e7f3a
Compare
pieh
commented
Oct 1, 2024
if (redirect === request.url) { | ||
logger.withFields({ rewrite_url: rewrite }).debug('Rewrite url is same as original url') | ||
logger.withFields({ redirect_url: redirect }).debug('Redirect url is same as original url') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like was previously c&p-ed from rewrite handling so log fields/msg was off
lukasholzer
approved these changes
Oct 1, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…ware-redirect-not-working
pieh
deleted the
michalpiechowiak/frb-1363-nextjs-i18n-middleware-redirect-not-working
branch
October 1, 2024 15:29
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We've been capturing original request locale and forcing it on redirects if redirect didn't contain locale. This was originally introduced in https://github.com/netlify/next-runtime-minimal/pull/276 . Since that PR we also had couple of iteration of i18n handling and the previous handling seems no longer needed and in fact it actually does break redirect functionality when
nextUrl.locale = '<default_locale>'
is being used - in which case thelocation
header for redirect would result in path that doesn't contain any locale (due to https://github.com/vercel/next.js/blob/eecf90c09ae2e39965191427776713c6b636e50f/packages/next/src/shared/lib/router/utils/add-locale.ts#L15-L17 ) and would fall into handling of adding original locale back.Tests
Initially failing test case added
Relevant links (GitHub issues, etc.) or a picture of cute animal
https://linear.app/netlify/issue/FRB-1363/nextjs-i18n-middleware-redirect-not-working