你好,
我使用 Azure/static-web-apps-deploy@v1 将静态网站部署到 Azure。 该网站被配置为只能由我们组织中具有自定义域的帐户访问。 到目前为止一切正常。
我想在 GitHub 中使用预览环境进行拉取请求。 在每个拉取请求中,都会创建一个新的预览环境,并动态生成该环境的 url。 他们总是看起来像这样:
https://random-name-{PRID}.westeurope.4.azurestaticapps.net
正确导航到该网址会返回错误:
AADSTS50011: The redirect URI 'https://my-random-page-3.westeurope.4.azurestaticapps.net/.auth/login/aad/callback' specified in the request does not match the redirect URIs configured for the application 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'. Make sure the redirect URI sent in the request matches one added to your application in the Azure portal. Navigate to https://aka.ms/redirectUriMismatchError to learn more about how to fix this.
手动添加生成的 URL 以重定向 Azure 应用程序中的 URL 效果很好。
如何自动化该配置,以便每个生成的预览环境都受到保护并且可以被我们组织中的任何人访问? 通过完成拉取请求,URL 也应该从配置中删除。
感谢您的帮助!
由于您的重定向 URL 为
https://my-random-page-3.westeurope.4.azurestaticapps.net/.auth/login/aad/callback
并且拉取请求 ID 是动态的,因此您可以使用 *
通配符来设置重定向 URL。
*
通配符以使重定向 URL 接受动态拉取请求。https://*.westeurope.4.azurestaticapps.net/.auth/login/aad/callback
。要在 Azure AD 中设置动态重定向 URL ,请使用以下 CLI 命令:
az login
az ad app update --id ApplicationID--add replyUrls "https://*.westeurope.4.azurestaticapps.net/.auth/login/aad/callback" --only-show-errors
在 Azure 门户中成功更新重定向 URL: