-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
Rewrites don't work if a middleware.ts file is present #51923
Comments
The problem is the locales, probably the same as this. It looks like Vercel doesn't care about i18n |
Agreed, there seemed to be an issue with localization in general when combining config rewrites with middleware as far as I've last noticed. But don't quote me on that |
Btw, it's working fine in development, but fails in production build :( |
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you. |
This issue has been automatically closed due to two years of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding! |
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.5.0: Mon Apr 24 20:52:24 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6000 Binaries: Node: 16.19.1 npm: 8.19.3 Yarn: 1.22.19 pnpm: N/A Relevant packages: next: 13.4.6 eslint-config-next: 13.4.6 react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3
Which area(s) of Next.js are affected? (leave empty if unsure)
Middleware / Edge (API routes, runtime), Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue or a replay of the bug
https://github.com/Reinano/custom-next
To Reproduce
1.next build && next start
2.Go to main page then click any link (about-1 or about-2).
3.Check router.query.slug
4. U'll be able to see empty router.query (useRouter)
Describe the Bug
I use rewrites and in the case when there is a middleware.ts file in the root of the project, then rewrites with a dynamic slug stop working.
I have rewrites like this:
const nextConfig = { reactStrictMode: true, async rewrites() { return [ { source: '/es-es/(quenes-somos)/:slug', destination: '/about/:slug', locale: false, }, ] } }
If i go to production build and start it. Next dev is ok.
After following the link
<Link href='/es-es/quenes-somos/about-1'>about-1 </Link>
from the main page to the about/[slug] dynamic page, I won't get router.query.slug.If u reload the page u can get router.query.slug
Router.query.slug available from getServerSideProps, but not in client side.
Expected Behavior
Would like to have access to router.query.slug from useRouter()
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: