How to configure Auth0 application to redirect to a specific URL after login?

Hello all,
I would like to understand how I can configure my Auth0 application settings to allow me to redirect to a particular route. Using localhost as an example URL, I am successful at getting the login to work. For example, my application URIs are:

  • Allowed Callback URLs: http://localhost:3000/callback, http://localhost:3000
  • Allowed Logout URLs: http://localhost:3000
  • Allowed Web Origins: http://localhost:3000

How can I update this correctly to use http://localhost:3000/app/ instead?

Thank you.

Hi @greggs

Welcome to the Auth0 Community, it’s great to have you on board.

You could create a post login Action to do the redirect as per this document

So for you it might look like this

exports.onExecutePostLogin = async (event, api) => {

Does this work for you?

Warm regards.

1 Like

This works great. I want to preserve the access to the user object that is provided by OAuth login. In this case, it sounds like I need to pass that information along as well. And to do that, I would need to follow the example on the same page of the documentation you provided.

I believe this will satisfy my goal. Thank you.

That’s great @greggs

Indeed this is one option, what Auth0 SDK are you using? some SDK’s have functionality to redirect after login.

For my node application I am currently using the express-openid-connect module. The version # is 2.8.0.

Within the actions, if we can reference the SDK, I am fine with the latest version. Does this help? It’d be great if there was an easier way to implement this.

Thank you for your guidance!

Hi @greggs

If you’re using our node SDK, the easiest thing to do might be to use the returnTo (the URL to return to after login) login option like this:

app.get('/login', (req, res) => res.oidc.login({ returnTo: '/app' }));

This is documented here

Some examples here

I hope this helps.

Warm regards