Auth0 Home Blog Docs

Logout with redirectTo passes to wrong URL from Allowed Logout URLs

logout

#1

Hi!
I tried to logout with redirect (Laravel 5.7):

$logoutUrl = sprintf(
‘https://%s/v2/logout?redirectTo=%s&client_id=%s’,
env(‘AUTH0_DOMAIN’),
urlencode(env(‘APP_URL’).’/pre_login’),
env(‘AUTH0_CLIENT_ID’));
return \Redirect::intended( $logoutUrl);

The URL is also mentioned in Allowed Logout URLs after one URLs used for development (they are completely different and comma-separated as described in docs).

Code in both applications is same, excepts data from env files.

My problem is - when I tried to logout using the code above - I was redirected to first URL from Allowed Logout URLs and it’s disappointing

So, is that my problem and I need to seek in my code for redirects normal behavior or I need to change something in application setting on auth0 side?


#2

Can you share the exact logout URL that the browser requests, and the 302 response returned by Auth0? (You can see this in the browser’s network tab in the developer tools)


#3

Thanks for fast answer!!!
Sure.

Logout URL that the browser requests
is: https://evinlort.eu.auth0.com/v2/logout?redirectTo=localhost%2Fwallter%2Fwallter%2Fpublic_html%2Fpre_login&client_id=pSsbQyNPgKmUFFLIUcwpq1Wm8TZyJAJY

URLs in Allowed Logout URLs are (as they present there):
https://crm-tst.wallter.com/pre_login, http://localhost/wallter/wallter/public_html/pre_login

Network tab in the developer tools


Detailed:

  1. Logout (local)

  2. Logout (auth0)

  3. Pre_login (my custom page. Must be local, but it redirected to remote app (not localhost))

If you need more info, I’m all yours :slight_smile:


#4

It looks as if you are using redirectTo as the parameter to indicate the return URL, but the parameter name should be returnTo.
Sorry I missed that in the original code snippet.


#5

Thank you Nicolas!
As I saw - all my troubles was my inattention to little things, such as returnTo and redirectTo.

Thanks again!


#6

Happens to all of us! :smiley: