Reputation: 75
so I recently got the login button to work with a netlify domain and now when I try to click the logout button, I get redirected to localhost:3000 but I want it to be redirected back to the page with the login button, is there a way to do that? here are my details for the URIs:
Allowed callback URLs:
http://localhost:3000,https://auth0-sample-authentication.netlify.app
Allowed Logout URLs
http://localhost:3000,https://auth0-sample-authentication.netlify.app
Allowed Web Origins
http://localhost:3000,https://auth0-sample-authentication.netlify.app
Please tell me if I need to include more code
Thanks,
324hz win21H2 he/him
Upvotes: 7
Views: 4332
Reputation: 260
To anyone looking at this question now you might be getting a typescript error with the above selected answer. You need to wrap the returnTo in a logoutParams object.
<button onClick={() => logout({ logoutParams: { returnTo: window.location.origin } })}>
Log Out
</button>
Upvotes: 8
Reputation: 75
The answer:
So it looks like all you have to do is in the button tag for the logout button you have to add this line here:
({ returnTo: "https://324hz.dev" })
so that the button looks something like this: (keep in mind this might not be your button layout)
<button onClick={() => logout({ returnTo: "example.com" })}>Log Out</button>
Where "example.com" is the address to the redirect.
Upvotes: 0
Reputation: 1843
If I understand you correctly, you need to add returnTo. It is said in docs https://auth0.com/docs/quickstart/spa/react/01-login
Upvotes: 1