【问题标题】:Deploying React application on azure在 Azure 上部署 React 应用程序
【发布时间】:2018-01-31 17:25:15
【问题描述】:

我正在尝试在 Azure 上部署我的 react 应用程序。这是一个我已经弹出的 create-react-app。我已经按照这篇文章进行了部署。我已将我的构建文件和 web.config 添加到我的站点/wwwroot 中。当我访问我的 webapp url 时,页面显示 “您无权查看此目录或页面。”

我在我的应用程序中使用客户端路由(react-router)。

这些是我的文件

web.config

<?xml version="1.0"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="React Routes" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

这就是我的项目在 azure 上的样子

【问题讨论】:

  • 在您的 wwwroot 目录下不需要索引或等效页面吗?
  • 我的 index.html 在公用文件夹中

标签: node.js reactjs azure create-react-app


【解决方案1】:

您需要转到应用程序设置并在虚拟应用程序中添加您的路径,如下所示:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-04
    • 2020-05-25
    • 2017-09-26
    • 2020-12-08
    • 1970-01-01
    • 2022-01-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多