Search code examples
next.jsauth0

Auth0 Signout issue - User href works but router.push doesnt?


Hi all here is my api route

import { handleAuth, handleLogin, handleLogout } from "@auth0/nextjs-auth0";

export const GET = handleAuth({
  login: handleLogin({
    authorizationParams: {
      audience: "https://reghound-api", 
      scope: "openid profile email offline_access view_checklists",
    },
  }),
});

When i use this link {user && <a href="/api/auth/logout">Logout</a>} the user is logged out.

When i use router.push router.push(/api/auth/logout); I am auto signed in and redirected to homepage. Why is this happening? I have also tried window.location.href to try and set logout url.


Solution

  • Argghhhhh! Figured it out!!! As i was calling logout url from serverside (in api route) I needed to add domain to allowed urls in CORS section