question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Removing `redirects()` from next.config.js does not work

See original GitHub issue

Bug 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

  1. Add an initial redirect function in next.config.js:
module.exports = {
    async redirects() {
      return [
        {
          source: '/foo',
          destination: '/bar',
          permanent: true,
        },
      ]
    },
  }
  1. Restart the server with yarn dev and see that /foo redirects to /bar.

  2. Remove the redirects function

module.exports = {
   
  }
  1. 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:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

14reactions
ijjkcommented, Sep 13, 2020

Hi, when setting permanent: true on a redirect it uses the 308 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 the permanent: false option.

3reactions
jonasdehovrecommented, Dec 28, 2021

What did the trick for me was opening the developer tools and in the network tab check the disable cache option 🙌

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found