The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Angular 14, AD B2C

Luis Diego Cáceres García 61 Reputation points
2022-08-04T15:47:08.84+00:00

Hi,

I´m deploying an Angular web app in App Services, with this web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="./index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>

</configuration>

When I started it, load the main page and when I try to login with AD B2C throw this error:

https://<app-service>.azurewebsites.net/home => not found in the console.

In the page: The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

This is my configuration B2C in Angular:

export const msalConfig: Configuration = {
auth: {
clientId: <client-id>,
authority: b2cPolicies.authorities.signIn.authority,
knownAuthorities: [b2cPolicies.authorityDomain],
redirectUri: 'https://<app-service>.azurewebsites.net/home',
},
cache: {
cacheLocation: BrowserCacheLocation.LocalStorage,
storeAuthStateInCookie: isIE,
},
system: {
loggerOptions: {
loggerCallback(logLevel: LogLevel, message: string) {
},
logLevel: LogLevel.Verbose,
piiLoggingEnabled: false
}
}
}

In my app registration in AD B2C:

Single-page application, Redirect URIs, configuration:

https://<app-service>.azurewebsites.net/home

When I tested it in my local machine, and use the configuration of

http://localhost:4200/home in the redirectUri and the same URI in the single-page-aplication redirect it works without problems.

I don't know what to do to solve the problem.

Regards,

Luis Cáceres.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,830 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,633 questions
{count} votes

Accepted answer
  1. ajkuma 22,086 Reputation points Microsoft Employee
    2022-08-22T07:02:56.567+00:00

    To benefit the community, posting our offline discussions.

    Cause: Misconfiguration in the application's web.config file caused a bad redirect after "sign in".

    Resolution: Change the following line in the web.config file so that it redirects to “/index.html” and instead of “/”:

    <action type="Rewrite" url="/index.html" />

    <configuration>  
    <system.webServer>  
    <rewrite>  
    <rules>  
    <rule name="Angular Routes" stopProcessing="true">  
    <match url=".*" />  
    <conditions logicalGrouping="MatchAll">  
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />  
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />  
    </conditions>  
    <action type="Rewrite" url="/index.html" />  
    </rule>  
    </rules>  
    </rewrite>  
    </system.webServer>  
    </configuration>  
    

    Thanks for your patience and cooperation! @Luis Diego Cáceres García . It's much appreciated!

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful