Removing `redirects()` from next.config.js does not work
See original GitHub issueBug report
Describe the bug
After removing the redirects
function from next.config.js, the redirects are still persisting. This should not happen since the redirects have been entirely removed.
To Reproduce
- Add an initial redirect function in next.config.js:
module.exports = {
async redirects() {
return [
{
source: '/foo',
destination: '/bar',
permanent: true,
},
]
},
}
-
Restart the server with
yarn dev
and see that /foo redirects to /bar. -
Remove the redirects function
module.exports = {
}
- Restart the server with
yarn dev
and see that /foo still redirects to /bar despite the fact that this has been removed.
Expected behavior
The redirect should no longer work after the redirect function has been removed.
System information
- OS: Ubuntu
- Browser: Chrome
- Version of Next.js: v9.5.3
- Version of Node.js: v12.18.3
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:9 (3 by maintainers)
Top Results From Across the Web
next.config.js: Redirects
Redirects allow you to redirect an incoming request path to a different destination path. To use Redirects you can use the redirects key...
Read more >NextJS redirects not redirecting urls after define in next.config ...
For anyone who has this problem, try restarting the server. The config file will be reloaded then.
Read more >How to implement redirects in Next.js - LogRocket Blog
Redirects enable users to transfer an executed URL to a new URL to reroute an incoming request from one path to another.
Read more >How to build URLs and handle redirects in Next.js | Kontent.ai.
The best practice is to handle these redirects in next.config.js . Solution 1: Switch Mode to fallback: blocking. You can solve this problem...
Read more >Project Config with vercel.json
Note: If you are using Next.js and running vercel dev , you will get a 404 error when ... Redirects do not require...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, when setting
permanent: true
on a redirect it uses the308
status code which instructs the browser to cache the redirect. To skip this cache you should be able to do a hard refresh in your browser. To prevent the redirect from being cached you should use thepermanent: false
option.What did the trick for me was opening the developer tools and in the network tab check the
disable cache
option 🙌