microsoft-authentication-library-for-js: redirectUri getting ignored

I include redirectUri when I invoke msal.js but after logging in on Azure AD B2C login page, user gets redirected to the page he/she came from, instead of the redirectUri I specify. Why is this happening?

Here’s my code

   var instance = '';
   var tenant = '';
   var signInPolicy = 'B2C_1_SignUp_SignIn';
   var applicationId = 'my-application-id';
   var scopes = [''];
   var redirectUri = '';
   var authority = `${instance}${tenant}/${signInPolicy}`;

   var clientApplication = new Msal.UserAgentApplication(
       function (errorDescription, token, error, tokenType) {
          // Handle error
            redirectUri: redirectUri

       var mySignInFunction() {

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 26 (11 by maintainers)

Most upvoted comments

@spottedmahn I can’t thank you enough!!!

@spottedmahn I have tears in my eyes!!! It’s working!!!

FYI, the code that controls the redirect behavior is here.

It is pretty simple. If navigateToLoginRequestUrl true then send the user back othewise don’t.

Any idea why the redirectUri is getting ignored?

I would turn on Preserve Log in Chrome debug tools


Then you can see the URL(s) your app navigated to. That might help diagnosis the issue.

I troubleshot the opposite of your problem w/ a fellow dev the other day. Turns out our AuthentactionGuard was causing problems and seeing URL the app navigated to help identify it.