Auth0 Home Blog Docs

Can't include a hash in a rule's redirect url

rules
redirect-rules

#1

I’m trying to incorporate a custom multi-factor authentication provider into the rules pipeline. If the user I am trying to authenticate requires an MFA code validation, I attempt to redirect them to a URL in the following format:

https://a.b.website.com/#/mfa/verify?token=URL_SAFE_TOKEN&state=AUTH0_STATE

I’m trying to accomplish this by ending my rule with the following snippet:

  context.redirect = {
    url: "https:/a.b.website.com/#/mfa/verify?token=" + token
  };
 return callback(null, user, context);

However, this ends up redirecting me to https://a.b.website.com/?state=AUTH0_STATE#/mfa/verify?token=URL_SAFE_TOKEN.

I removed the # from the redirect URL by ending my rule with the following snippet:

  context.redirect = {
    url: "https:/a.b.website.com/mfa/verify?token=" + token
  };
 return callback(null, user, context);

This ends up redirecting me to a sane URL, https://a.b.website.com/mfa/verify?token=URL_SAFE_TOKEN&state=AUTH0_STATE, but this isn’t viable for me.

Am I missing another way to include a # in the redirect URL or is it not possible at this time?


#2

Can you help me understand in your code why you need a # in the redirect URL?


#3

The goal is to redirect to an angular app that already has a # in the URL for routing.