Logout redirect URL when auth0 session expires


I’ve got an Angular app using the auth0-angular package. On my site, I’ve got an admin portal and a client portal. The admin site is accessible at https://my-domain/admin/, while the client portal is accessible at https://my-domain/. I have a way to manually log out by clicking an a dropdown menu option in the header bar on my site. This essentially calls the following, where “path” is either an empty string (if the user is currently on the customer portal), or “/admin” (if they are currently on the admin portal:

   returnTo: 'https://' + window.location.host + path,

When I log out this way, things work just fine: if I was on the admin portal before, then logout - which redirects me to our auth0 Universal Login page - then log in again, I will get redirected to “https://my-domain/admin”. And if I was on the customer portal, click logout, then log back in again, I will get redirected to “https://my-domain”. So, everything works as expected here.

The issue is when my Auth0 session expires while I’m on the site. Regardless of whether I’m on the admin portal or the client portal, if my session expires, I will get logged out to the root of my site, which then prompts a redirect to my Universal Login page. Once I log in there, I will then get redirected to the customer portal: “https://my-domain”. Ideally, I’d like to be able to control where I get logged out to when my session expires, so that if I’m on the admin portal, I will be able to log in again and get brought back automatically to the admin portal at “https://my-domain/admin”, instead of the customer portal. How can I achieve this?