gpt4 book ai didi

azure - 验证 Azure 静态 Web 应用程序时出现 404 错误

转载 作者:行者123 更新时间:2023-12-02 05:57:17 39 4
gpt4 key购买 nike

我在 Azure 中创建了一个静态 Web 应用程序。这只是一个只有 HTML 页面的普通网站。我能够部署和访问该应用程序。

问题是当我尝试将 Azure Active Directory 与此服务集成时。我的staticwebapp.config.json如下。

{
"routes":[
{
"route": "/login",
"rewrite": "/.auth/login/aad"
},
{
"route": "/*",
"allowedRoles": ["authenticated"]
}
],
"auth": {
"identityProviders": {
"azureActiveDirectory": {
"registration": {
"openIdIssuer": "https://login.microsoftonline.com/<tenant id removed>",
"clientIdSettingName": "<client id value>",
"clientSecretSettingName": "<client secret value>"
}
}
}
},
"responseOverrides": {
"401": {
"redirect": "/login",
"statusCode": 302
}
}
}

此后,当我尝试访问任何页面时,它会被重定向到/login 并收到 404 页面。我预计它会转到 azure 身份验证页面(由于重定向规则)。是否还需要进行任何其他配置来验证静态 Web 应用程序?

最佳答案

这里需要仔细检查的一件事是 clientIdSettingNameclientSecretSettingName 字段。

这些不是实际值,而是对 SWA settings引用 。这样做的原因是为了确保不会将纯文 native 密提交给源代码管理。

因此,给定文字值

"clientIdSettingName": "AZURE_CLIENT_ID",
"clientSecretSettingName": "AZURE_CLIENT_SECRET"

Azure 门户应设置如下: azure portal showing SWA configuration parameter names

Documentation明确提到了这一步,但在前几次通读时我错过了此设置的引用性质。最终,变量名称泄露了它。

关于azure - 验证 Azure 静态 Web 应用程序时出现 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68521349/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com