-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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 with i18n #28921
Comments
Is it possible to prioritize this issue? Rewrites not working when i18n is enabled is a pretty big issue according to me. Rewrites are especially useful for i18n projects, as it lets you group pages in folders and rewrite those folder names depending on the locale of the user. Otherwise, the only way to do so is using Dynamic Routing, but you can't have 2 dynamic routes at the same level in a folder structure, which makes it non-viable for us in the projects we are working on, as most pages are rendered in a Catch-all dynamic route, so our folder structure looks like:
If we want the I got here after finding the issue #28863 I have exactly the same problem... The rewrites work fine for me locally or when doing |
We're experiencing the same issue. I've also tried it with next v12, but the issue perssits. As the person above me described, it only happens when deploying to vercel. Locally the production build works fine. |
Same here, we just configured i18n.locales and now all of our api rewrites give us 404 errors. |
We've also run into this issue:
So it seems the issue is a combination of:
All of the deploys below use the exact same codebase (except for nextjs version and next.config.js refconfiguration) and backend. Deploy (next12.0.7) where dispatcher uses /api and fails (note Deploy (next12.0.7) where dispatcher uses /backend and works: For completeness sake heres also a deploy with next11.0.1 where /api calls work: While the workaround can be made to work as described it's still problematic for some of our tenants as some also use 3rd party integrations that make use of the existing /api rewrites. |
Same issue here with |
It also happens with apps not deployed to Vercel :( this is a blocker |
Same issue here with re-routing to an external API. |
I am in the same boat--rewrites working fine with i18n except for POSTs prefixed with /api/, and even then it only 404s once deployed. Does anyone more next.js savvy than me have any idea where to start to look for this bug? I'd gladly take a stab at it, if I had a sense of where to begin. |
I think this is more of a vercel bug, than a next.js bug. |
That makes sense, though complicated slightly by reports in this thread that it's also a problem hosting elsewhere. Regardless, if it's not a next.js bug, are we discussing it in the right place? |
We have the same issue, with the following config i18n: {
locales: ['en', 'es'],
localeDetection: false,
},
async rewrites() {
return [
{
source: '/my/path/:slug*',
destination: '/my/other-path/:slug*',
},
]
}, with |
I could recreate this here, even using We will look into this. |
This ensures non-matching API routes can be rewritten with i18n configured as currently we bail and render the 404 page when a locale prefixed API route is requested. ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` x-ref: [slack thread](https://vercel.slack.com/archives/CGU8HUTUH/p1643930049224689) closes: #28921
Hi, this has been updated in |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
11.1.2 and 11.1.3-canary.14
What version of Node.js are you using?
14 and 16
What browser are you using?
Chrome Firefox Insomnia
What operating system are you using?
Windows, Linux
How are you deploying your application?
Vercel
Describe the Bug
It seems that we cant run POST requests while using i18n on the latest version (it was working on 11.0.x and 11.1.0 but not 11.1.1+)
Expected Behavior
request shouuld be rewrote to the other path
To Reproduce
Minimal Github repository
https://github.com/Aviortheking/tests-nextjs
The text was updated successfully, but these errors were encountered: