If an endpoint is called via Ajax calls from JavaScript-based clients, CORS configuration is required.
This can be done by setting the AllowedCorsOrigins
collection on the client configuration. IdentityServer will consult these values to allow cross-origin calls from the origins.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Client | |
{ | |
ClientId = "angularClient", | |
ClientName = "JavaScript Client", | |
RequireConsent=true, | |
AllowedGrantTypes = GrantTypes.Implicit, | |
AllowAccessTokensViaBrowser = true, | |
RedirectUris = { "http://localhost:4200" }, | |
PostLogoutRedirectUris = { "http://localhost:4200" }, | |
AllowedCorsOrigins = { "http://localhost:4200" }, | |
AllowedScopes = | |
{ | |
IdentityServerConstants.StandardScopes.OpenId, | |
IdentityServerConstants.StandardScopes.Profile, | |
IdentityServerConstants.StandardScopes.Email, | |
"api1" | |
} | |
} |
Remark: Be sure to use an origin (not a URL) when configuring CORS. For example: https://foo:123/
is a URL, whereas https://foo:123
is an origin.