尝试重定向到 Azure AD 进行身份验证时遇到 CORS 策略问题

I'm getting a CORS policy issue when trying to redirect to Azure AD for authentication

我收到这个错误:

Access to XMLHttpRequest at 'https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize/.well-known/openid-configuration' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

尝试重定向到 Azure 进行登录时。

这是服务:

export class AuthService {
private _userManager: UserManager;

constructor(private http: HttpClient) {
    const config = {
        authority: Constants.stsAuthority,
        client_id: Constants.clientId,
        redirect_uri: `${Constants.clientRoot}assets/oidc-login-redirect.html`,
        scope: 'openid profile',
        response_type: 'id_token token',
        post_logout_redirect_uri: `${Constants.clientRoot}?postLogout=true`,
        userStore: new WebStorageStateStore({ store: window.localStorage })
      };
    this._userManager = new UserManager(config)
 }

 login(): Promise<any>{
     return this._userManager.signinRedirect();
 }

}

我确定我的 localhost url 注册正确。然而,我收到了那个错误。到目前为止,我没有看到任何与此相关的文档。

感谢您的帮助

https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize/.well-known/openid-configuration 不是有效的 URL。

可能是你的权限设置有误。 它应该只是 https://login.microsoftonline.com/tenant-id