next-runtime
next-runtime copied to clipboard
[Bug]: Redirects are not working in the deployed application
Summary
When I create a app with netlify and add a _redirects file and serve it with ntl dev it's working on the deployed app it's not
Steps to reproduce
- Clone this repo: https://github.com/lukasholzer/netlify-next-redirect-issue
- Ntl dev (on the home page it should use the redirect)
- Check out the deployed version (not working) https://main--euphonious-swan-75085e.netlify.app/
The site: https://app.netlify.com/sites/euphonious-swan-75085e/overview
A link to a reproduction repository
https://github.com/lukasholzer/netlify-next-redirect-issue
Next Runtime version
should be the latest in the CI
More information about your build
- [ ] I am building using the CLI
- [ ] I am building using file-based configuration (
netlify.toml)
What OS are you using?
Mac OS
Your netlify.toml file
`netlify.toml`
# Paste content of your `netlify.toml` file here
Your public/_redirects file
`_redirects`
/ /foo
Your next.config.js file
`next.config.js`
# Paste content of your `next.config.js` file here. Check there is no private info in there.
Builds logs (or link to your logs)
Build logs
# Paste logs here
Function logs
Function logs
# Paste logs here
.next JSON files
generated .next JSON files
# Paste file contents here. Please check there isn't any private info in them
# You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time.
This is your answer 😁 https://app.netlify.com/sites/euphonious-swan-75085e/deploys/63bd91ffe5d0c10009779bc0#L227
oh my gosh I just should have read that! but I think it's still strange that it's working in ntl dev and not in prod (provides a wrong safety feeling).
Especially If I move it to the public folder it's not working locally anymore with ntl dev
Yeah, that has to be a bug. I wonder if dev is looking in the wrong publish dir
~~@lukasholzer @ascorbic One thing to note, the docs mention a _rewrites and _headers should be moved to the /public folder, but it doesn't mention _redirects (potentially just a brain fart accidental renaming?)~~
~~The docs could of course be updated to say _redirects rather than _rewrites, but as mentioned, that doesn't seem to then make things work in dev.~~ (Note: docs updated in: https://github.com/netlify/next-runtime/pull/1895)
Similarly, this I believe potentially conflicts with NextJS's basePath config option, as since anything in public is hoisted to the basePath defined folder, we can seemingly never do something like redirect the root path ("/") to the base path, so the preview urls of https://your-subdomain-here.netlify.app will 404, and we need to manually go to https://your-subdomain-here.netlify.app/your-base-path-here
(Note: https://docs.netlify.com/integrations/frameworks/next-js/redirects-and-rewrites/ mentions to not add a root-level rewrite, but next.config.js redirects I believe won't catch on the root "/" if setup with a basePath config.)
how do you guys solve this?, can't see the logs
@ascorbic Is this still valid for v5?