Redirection to the specific sub directory after a successful login

Hi everyone;

I have an angular app which is deployed to the specific sub directory, say this is the path to the angular app:

https://dev.mydomain.com/directory1/directory2

Now if I try to log in and after successfully logging in, it’ll be redirected to https://dev.mydomain.com and the path will be removed from the url

How can I handle the redirection to make sure it’ll be redirected to https://dev.mydomain.com/directory1/directory2 without the path being removed ?

I’ve also set the Allowed Callback URLs, Allowed Logout URLs, Allowed Web Origins fields to the app url https://dev.mydomain.com/directory1/directory2

I’m noticing when I log in, for a short period of time it’ll be redirected to this url: https://dev.mydomain.com/directory1/directory2?code=xyz&status=xyz but then at the moment that it removes the code and status query strings it also removes the /diretory1/directory2 path from the url and redirects to the wrong url: https://dev.mydomain.com

any suggestions?

1 Like

Hi @hamid.behnam,

Welcome to the Auth0 Community! :tada:

We have a document that explains how to redirect users to other URLs. For more information, please check this document:

Let me know if that helps!

1 Like

Thanks for helping on this front Lily!

@lily.wisecarver thanks for the reply the link doesn’t provide the solution for this issue.

The following are the steps to reproduce the issue even with the official angular sample app:

  • Created a component called SectionComponent
  • Updated the routing to add /section route
  • Added redirectUri: window.location.origin + '/section' in auth config
  • Set Allowed Callback Url to http://localhost:4200/section
  • Set Allowed Logout URL to http://localhost:4200
  • Set Allowed Web Origin to http://localhost:4200/section
  • Saved the application settings

Now when I log in, I expect to be redirected to http://localhost:4200/section but the problem is I see it’s redirected to http://localhost:4200/section?code=xyz&state=xyz for a short period of time then it’ll be redirected to http://localhost:4200

Am I doing something wrong?

Hi @hamid.behnam,

Can you please send me a .har file of the login flow in a private message? It would be a great help if you could capture this login session in a trace file. Full instructions here: Generate and Analyze HAR Files

Please make sure you select the Preserve log checkbox.

Before sending the HAR file back to me for analysis, be sure to remove/censor any sensitive information using a text editor (i.e., remove passwords, secrets, etc.).

If the file is greater than 15MB in size, then please zip it up.

Let me know if creating a HAR file presents you with any problems.

Thanks @lily.wisecarver, I just sent the har file.

1 Like

Hi @hamid.behnam & @lily.wisecarver ,
I’m faceing the sama issue.
Where you able to solve it?
Thanks in advance!

Sorry, playing just a bit I’ve created a subdomain and now it works perfect
Instead of “https://mydomain.com/appWithAuth0/” I have “https://appWithAuth0.mydomain.com/
That works perfect!