Skip to content
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

Can't sign out, automatically signs in immediately #1744

Open
6 tasks done
cutesweetpudding opened this issue May 9, 2024 · 8 comments
Open
6 tasks done

Can't sign out, automatically signs in immediately #1744

cutesweetpudding opened this issue May 9, 2024 · 8 comments

Comments

@cutesweetpudding
Copy link

Checklist

Description

Everything works fine in local, I implement same way as example app. Just login/logout, however after deploy to azure static web, it fails to signout, always immediately signs back, which extremely annoying. I have tried all solutions online, and wasted 2 days on this issue, still can't figure it out. Attach a screenshot, logout v2 url is called, but session / cookie not cleaned, I even tried to manually clean it, but it adds back immedately.

Screenshot 2024-05-08 at 10 59 45 PM

Reproduction

Just deploy azure static website, I think this is common issue.

Additional context

n/a

nextjs-auth0 version

3.5.0

Next.js version

8.1.0

Node.js version

v20.8.0

@JeroenMinnaert
Copy link

JeroenMinnaert commented May 14, 2024

Same issue over here, not sure what's going on. Tried changing to links as instructed here, but that didn't help. I'm running this on an AWS stack and Cloudfront.

Might be related to #42?

@zlatkopetrov
Copy link

Same issue here. Using Azure static website.

@JeroenMinnaert
Copy link

From my part, it looks like this is related to the cache policy in my Cloudfront.

I've deployed using SST and the NextJs construct.

@JeroenMinnaert
Copy link

I found a fix for this issue in my stack. Since Auth0 uses Cookies for authentication, I had to explicitly set cookieBehavior: CacheCookieBehavior.all() (default it is set to none). Spent a long time looking for this solution, I hope this helps someone else.

Below is the full code:

  const nextJsSite = new NextjsSite(stack, "next-js-site", {
    path: "packages/web",
    cdk: {
      // By default, the cache policy is configured to cache all responses from
      // the server rendering Lambda based on the query-key only. If you're using
      // cookie or header based authentication, you need to override the
      // cache policy to cache based on those values as well.
      serverCachePolicy: new CachePolicy(stack, "ServerCache", {
        queryStringBehavior: CacheQueryStringBehavior.all(),
       // The headers below are set by the SST construct so adding this as well
        headerBehavior: CacheHeaderBehavior.allowList(
          "accept",
          "rsc",
          "next-router-prefetch",
          "next-router-state-tree",
          "next-url",
          "x-prerender-bypass",
          "x-prerender-revalidate",
        ),
        // The line below solved my problem
        cookieBehavior: CacheCookieBehavior.all(),
        defaultTtl: Duration.days(0),
        maxTtl: Duration.days(365),
        minTtl: Duration.days(0),
      }),
    },
  });

@zlatkopetrov
Copy link

Has anyone found a solution for this issue? The cookie is not removed after successful logout, so the users are still logged in.

@altrim
Copy link

altrim commented May 27, 2024

I’m facing the same issue while deploying Next.js to Azure Static Web Apps. Logout works fine locally, but it doesn’t seem to work when deployed. Even though all requests in the network tab appear to be fine, it keeps signing in automatically.

@kaayru
Copy link

kaayru commented Jun 5, 2024

Same problem here.

@larspietrowski
Copy link

I have the same problem. Locally works fine, but on azure static web apps the user ist still logged in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants