handleLogout Redirect Issue

Hello team,
In my application, I am using nextjs version as 12.2.3 page based routing and autho very old version as 1.3.1. I did all configuraion required as per documentation right from tenant callback url configuration to the testing whitelist any urls if?

Problem over here is login is getting in but logout is not working at all.
handleLogout is getting invoked but its returnTo is not getting activated or in action.

Please help me and give me some suggestions

Hello,

Let’s address the logout issue in your Next.js application with Auth0. Here are some steps and suggestions to troubleshoot:

Check Callback and Logout URLs:
Ensure that you’ve correctly configured the Allowed Callback URLs and Allowed Logout URLs in your Auth0 application settings.
The callback URL should match the route where Auth0 redirects after successful login (e.g., http://localhost:3000/api/auth/callback).
The logout URL should match where Auth0 redirects after logout (e.g., http://localhost:3000).
Verify that these URLs are correctly set in your Auth0 dashboard.
Testing Logout Directly:
While your app is running locally, try testing the logout by directly pasting this URL into your browser:

https://your-auth0-domain/v2/logout?client_id=your-client-id&returnTo=http%3A%2F%2Flocalhost%3A3000%2Ftest-logout
Replace your-auth0-domain and your-client-id with your actual Auth0 domain and client ID.
This should log you out and redirect you to the specified test-logout page.
Session Persistence:
Make sure that your Next.js session is being cleared properly when calling the logout function.
If you’re using NextAuth.js, it should handle session management for you. Ensure that you’re using the correct version of NextAuth.js and that it’s configured properly.
Federated Logout (OIDC):
NextAuth.js currently does not support federated logout (OIDC compliant). It clears the session cookie on the browser side but not on the Identity Provider (Auth0) itself.
To achieve federated logout, you can create a custom logout function that calls the Auth0 end session endpoint and then redirects back to your website. Example:

// Custom logout function
const logout = async () => {
  await signOut({ callbackUrl: "/api/auth/logout" });
};

In your /api/auth/logout route, handle the end session with Auth0 and redirect back to your site.
Testing Multiple Tabs:
Sometimes issues arise when multiple tabs are open. Test the logout behavior with multiple tabs to ensure consistency.
Remember to replace placeholders like your-auth0-domain and your-client-id with your actual values.

Hope this work for you.
Best regards,
thomas945

Hi Thanks for the reply I tired all these steps but nothing working
Verified client id and logout redirection URL also which i configured already. Problem here which I am guessing I am using @auth0/next-js@auth0 1.3.1 which is old version in this returnTo url got deprecated which is my guess because in internal library url.parse not working
So pls suggest the another alternative.
If I update will it work ? Lot of trials happened sir already