How to allow list of URL's in Auth0 after mentioning particular path

Hello Team,

I have used the callback URL before to allow the user to enter a particular url after the login operation is done and before I have given a static url in callback for example “https://dev.auth0.com/report_fleet” and it works fine completely. But now I have a new requirement where my URL varies for each operation after a particular path for example “https://dev.auth0.com/report_snapshot/11 or https://dev.auth0.com/report_snapshot/100 or https://dev.auth0.com/report_snapshot/200” is there a way to allow all the url’s after the following path “https://dev.auth0.com/report_snapshot/”. I am new to Auth0 can you please help me to figure out this issue and provide me a detailed step of how to achieve this.

1 Like

Hi Team,

Sorry for pushing on this request I know its too early to follow up but I have my production release on coming Friday so it will be great if I get some response as soon as possible from you guys :slight_smile:

Hi @vignesh.ramesh,

As mentioned in this topic, unfortunately you cannot use a wildcard to match several callback URLs. Instead the suggested way to handle multiple routes is to use a single callback route (e.g. /callback) and redirect to the desired route from within your application:

  1. Store the following in localStorage: randomStateValue : the URL pathname.

  2. Pass randomStateValue as the state parameter in the authentication request.

  3. Check the state value in the callback, and retrieve the value for randomStateValue from localStorage.

  4. Perform the redirect from within your application.

Hello @stephanie.chamblee ,

Thanks for providing the solution, I will implement this from my end and let you know if I face any issue

1 Like

Hi @vignesh.ramesh,

I noticed this issue and realized that the Auth0 SPA SDK has its own way of storing state that can be retrieved from when you call handleRedirectCallback:

// set state when you request redirect
client.loginWithRedirect({
  appState: { 'randomString': '/report_snapshot/200' }
});

// Retrieve the state
const { appState } = handleRedirectCallback();
const redirectPath = appState[redirectKey];

I updated the example above.

Hello @stephanie.chamblee ,

Thanks for providing me the solution , it works fine :slight_smile:

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.