-
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
Support next.config.js redirects, rewrites, headers #150
Comments
Hey @scopsy, Thank you for the kind words and for filing this issue to make I had a closer look at the NextJS experimental syntax for redirects and rewrites as well as the limitations that apply to redirects on Netlify. There are a couple issues: Netlify's redirect syntax is a lot more narrow than the one used by NextJS Netlify only supports redirects with plain text, with parameter placeholders (
There is no direct way to express that in a Netlify-compatible way. With Netlify, you would probably define it as a catch-all So it's possible to express the same rewrite in Netlify, but I can't think of a way to automatically translate a redirect like the one you shared into the Netlify equivalent, correctly deciding if the rewrite should be at the very top or the very bottom of the list. Netlify only redirects/rewrites once per request I need to double check this, but my understanding is that Netlify only redirects or rewrites once per request. All server-side rendered pages and all pages with dynamic paths already require one redirect. For example, we may have a SSRed page called One way to correct for that would be to evaluate the redirects at build-time. For example: Next Steps What do you think? Do you have ideas for how this could work? In your specific case, you could just work around it for now: The first two redirects are not needed for Netlify (because they normalize the URLs and trailing slashes anyway) and the last two rewrites you could manually add as one single rewrite in your
It would catch any unmatched path and call your API endpoint. Not what you were hoping for, I'm sure, but that's my best idea at the moment. Let me know what you think! |
This is now fully supported (not experimental) in Nextjs. is this something that will be eventually added / supported? I would like to consider moving an app to netlify but currently it does use nextjs redirects and rewrites and so would be tricky not having those work anymore if I decide to move it =) thank you! happy netlify client ;) |
i have the same problem of @scopsy |
i need the rewrites next.config.js |
To be clear: custom header in next.config.js are not supported?
|
Hi all, jumping on this issue because we're facing a possibly related problem: We want to create a rewrite to our api routes using the netlify.toml file, looking like this:
However, it seems like all of the requests to Is this a known issue or am I doing something wrong? When I configure non-api route redirects in the netlify.toml file, everything works as expected 🤔 |
Fixed in version 4 |
I cannot for the life of me get a CSP header set on the root page of my nextjs/netlify app. next.config.js:
netlify.toml
_headers
Any guidance? thx |
Having similar issue, any resolution? |
Hey, Have you solved this problem? I encountered it too |
* fix: handle parallel routes default layout * Fix tests * Check that it's app router * Add fs check * Don't worry about missing default.meta
First of all, thank you for the amazing work with this package!
Currently when defining experimental rewrites in
next.config.js
they are not respected in netlify and throw 404 error from netlify. Any chance they can be supported?example of the config file:
The text was updated successfully, but these errors were encountered: