【发布时间】:2020-10-18 19:24:32
【问题描述】:
我使用routes.json 将我的静态网站(React 应用)部署到 Azure 应用服务,以启用 HTML5 路由回退。我的路由 json 位于 /public 中,可在 URL https://mywebsite.azurewebsites.net/routes.json 下找到。
{
"routes": [
{
"route": "/*",
"serve": "/index.html",
"statusCode": 200
}
]
}
重定向不起作用。我做错了什么?
【问题讨论】:
-
我已经更新了我的答案。从您的 url 地址,我确定您使用的服务不是
static web apps。如果你创建static web apps,你的url地址应该是`yourstaticwebapp.azurestaticapps.net`。 -
@JasonPan 感谢所有这些截图和解释。我还没有在 github 上尝试过,但我确信它可以工作。是的,绝对的,我会接受你的回答!
-
routes.json 文件现已弃用,但路由、覆盖和身份验证规则现在都在 staticwebapp.config.json file 中定义。
标签: reactjs azure azure-web-app-service azure-static-website-hosting azure-static-website-routing