Auth0 Logout Not Fully Clearing Session on Azure Static Web Apps

I’m experiencing an issue where logging out from Auth0 works locally but fails on Azure Static Web Apps. Even after calling /api/auth/logout, the session remains active, and Auth0 cookies (appSession, auth_verification) are restored.

What I Have Tried:

:white_check_mark: Ensured the Auth0 logout URL is correctly set in the Auth0 dashboard.
:white_check_mark: Used /api/auth/logout instead of a direct redirect to Auth0’s logout URL.
:white_check_mark: Tried clearing cookies manually (client-side and server-side) but appSession persists.
:white_check_mark: Called /.auth/logout before redirecting to /api/auth/logout. However, a cors error occurs when making this request.
:white_check_mark: Disabled caching using Cache-Control: no-store, no-cache, must-revalidate.
:white_check_mark: Tested in Incognito mode to rule out local caching.

Observations:

  • Deleting cookies manually via the browser instantly logs out the user, but doing so via code does not work.
  • Azure appears to be restoring the session cookies after logout.

Questions:

  1. Is there a way to prevent Azure from persisting authentication cookies?
  2. How can we fully clear the Auth0 session when logging out on Azure Static Web Apps?

Hi @dato.bobokhia,

Welcome to the Auth0 Community.

I found this issue on the Static Web App Github repo with this comment saying logouts from custom IdPs are not supported:

This thread has some fixes that could work for your case.

If you have any other questions feel free to ask us.

Have a good one,
Vlad