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.

Incompatibility with next.js redirects

See original GitHub issue

Issue

If redirects are configured in a next config the sessions don’t seem to make it into session storage, which results in a redirect back to login, which then redirects back to the app - this cycle happens indefinitely.

Steps to reproduce:

  1. Add a new route file (e.g., test.js)

  2. Configure a redirect in a next.js config file (e.g., in a next.config.js file in the root directory):

/** @type {import('next').NextConfig} */
const nextConfig = {
  async redirects() {
    return [
      {
        source: '/',
        destination: '/test',
        permanent: false,
      },
    ]
  },
}

module.exports = nextConfig

Versions

  • react-oidc v6.5.7
  • next v12.2.5
  • react v18.2.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
madzecommented, Sep 29, 2022

@guillaume-chervet - Yes, absolutely! Sorry, I should have added that in the last message.

0reactions
guillaume-chervetcommented, Sep 29, 2022

Thank you very much @madze

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 >
React Next js app redirect to login is premature - Stack Overflow
The problem is when a user is logged in and directly goes to /user/dashboard route, for a split second, user is undefined may...
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 >
Capture group in redirect source causes Uncaught SyntaxError
Add a new redirect to your next.config.js as follows: { source: '/:path((?!incompatible).*)', destination: '/incompatible', permanent: false ...
Read more >
Duplicate content and no default Next JS redirect from trailing ...
I have deployed next.js 11.1.0 test site and noticed that the redirect from trailing slash is not functional. Both URLs load creating duplicate...
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