Blazor WebAssembly Oidc 身份验证在本地工作正常,但在 Azure 静态 Web 应用程序上有 404 身份验证/登录回调

时间:2020-12-19 03:01:52

标签: blazor-webassembly .net-5

我有一个使用 Auth0 OIDC 身份验证的 Blazor .Net5 WebAssembly。我按照以下说明设置了身份验证:https://auth0.com/blog/securing-blazor-webassembly-apps/

按照这些说明,我能够在本地开发我的应用程序并使其与 Auth0 身份验证一起使用。但是,当我使用 Azure 静态 Web 应用部署应用程序时,身份验证不再起作用。查看Chrome的开发者工具我可以看到它成功(302)调用了我的授权端点:

https://login.mysite.com/authorize?clientid=*****...  (302)

下一个 url 是对我网站的回调,它以 404 失败:

https://myapp.mysite.com/authentication/login-callback?code=***... (404)

我的 index.html 中有以下内容:

<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script>

知道我可以做些什么来解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

我添加了一个 routes.json 文件到 wwwroot 以解决这个问题。

{
  "routes": [
    {
      "route": "/*",
      "serve": "/index.html",
      "statusCode": 200
    }
  ]
}