Session cookie or localStorage sounds like a valid approach, I’d also go that route. After the callback from Auth0 back to your site, read out the localStorage or cookie and make the further redirect to the topic page again.
There is another option, but I don’t see much of a benefit there (esp. because I’d like to avoid wildcards in callback url patterns):
You could allow for a callback url with a wildcard like:
in your client applications settings in the Auth0 dashboard, and then, when the user got logged out and needs to re-login, pass that as
redirect_uri parameter accordingly in the authorization request to Auth0, like:
Once the callback happens, you handle the redirect based on that parameter.
@aevlanov Updated answer with an alternative, though I wouldn’t consider it being better.