【问题标题】:React Router not working On Azure Wep App Linux serviceReact Router 在 Azure Web App Linux 服务上不起作用
【发布时间】:2021-12-28 11:13:58
【问题描述】:

我已经使用 Parcel v2 构建了 React 应用程序并将其部署到 Azure Wep App Linux 服务,但那里的路由器无法正常工作。 如果您使用应用内按钮和导航,则可以,但如果您尝试输入任何链接,则会出现 404 未找到。 本地一切都按预期工作 我还尝试了这些问题的解决方案: Deploy react js web app on linux app Service azure

React Router throwing 404 on Azure Linux Web App

【问题讨论】:

    标签: azure-devops azure-web-app-service


    【解决方案1】:

    在您的 azure 仪表板 > 配置 > 启动命令中添加此命令

    pm2 serve /home/site/wwwroot --no-daemon --spa
    

    然后重启你的服务器。

    • 这告诉主机将正确的目录作为您网站的根目录,--spa 标志表明这是一个单页应用程序,因此路由会自动定向到您的根 index.html 文件,而不是实际搜索一个不存在的目录。保存此内容,然后重新启动您的应用服务。

    详情请参考Deploying a React app to Azure App Service的第16点。

    【讨论】:

    • 如问题中所述,此解决方案不能解决问题。应用程序甚至没有启动
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-05
    • 1970-01-01
    • 2018-08-21
    • 2017-08-31
    • 2019-10-01
    • 1970-01-01
    相关资源
    最近更新 更多