-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Closed
Labels
bugIssue was opened via the bug report template.Issue was opened via the bug report template.
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022
Binaries:
Node: 14.17.0
npm: 6.14.13
Yarn: 1.22.17
pnpm: N/A
Relevant packages:
next: 12.2.5
eslint-config-next: N/A
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
Firefox Developer Edition 98.0b10 - Firefox 97.0.2 - Chromium 99.0.4844.51
How are you deploying your application? (if relevant)
yarn dev OR yarn build && yarn start
Describe the Bug
Here is my next config:
{
i18n: {
locales: ['en', 'fr'],
defaultLocale: 'en',
},
async redirects() {
return [
{
source: '/fr/about',
destination: '/fr/a-propos',
locale: false,
permanent: false,
},
]
},
async rewrites() {
return {
beforeFiles: [
{
source: '/a-propos',
destination: '/about',
},
],
}
},
}
Without any middleware, or with a middleware without matcher
config, everything works as exected.
But if I add this config, { matcher: ['/about'] }
to the middleware, then the /fr/a-propos
page is broken on CSR: the props from getStaticProps are not received by the page because there is a wrong redirection, from /_next/data/development/fr/about.json
to /fr/a-propos
.
Expected Behavior
The middleware should not conflict with the rewrites/redirects.
Link to reproduction
Repo Github
Repo on CodeSandbox
CodeSandbox deployment
To Reproduce
- Open the provided reproduction
- Install the dependencies:
yarn install
- Run with either
yarn dev
oryarn build && yarn start
- Visit
http://localhost:3000/
- Follow the guided visit, or...
- Open the network tab of your browser
- Click the
Visit /fr/a-propos
link - See that the props from getStaticProps are empty
- See that there is a weird redirection from
/_next/data/development/fr/about.json
to/fr/a-propos
.
abennani15, dsm-ostec, KVRA, mlake, dobrud and 7 more
Metadata
Metadata
Assignees
Labels
bugIssue was opened via the bug report template.Issue was opened via the bug report template.