'Reroute to original route when authentication completes react-msal

export const msalConfig = {
auth: {
    clientId: process.env.REACT_APP_B2C_CLIENT_ID, // This is the ONLY mandatory field that you need to supply.
    authority: b2cPolicies.authorities.signIn.authority, // Choose SUSI as your default authority.
    knownAuthorities: [b2cPolicies.authorityDomain], // Mark your B2C tenant's domain as trusted.
    redirectUri: '/home', // You must register this URI on Azure Portal/App Registration. Defaults to window.location.origin
    postLogoutRedirectUri: "/", // Indicates the page to navigate after logout.
    navigateToLoginRequestUrl: false, // If "true", will navigate back to the original request location before processing the auth code response.
}}

This is the msalConfig. When I input browser's address bar '/dashboard', and I met MSAL signin screen. After the success of authentication I only navigate to '/home' route as defined in configuration. I want to navigate '/dashboard' (the input url, not fixed configuration url) after success of authentication. How can I change the msalConfig for that? Please help me.



Solution 1:[1]

You probably need to set 'navigateToLoginRequestUrl : true'.

It should redirect to the page (post authentication) that initiated the request.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 curious