在Azure上部署React应用程序后出现错误

时间:2020-08-21 15:57:29

标签: node.js reactjs azure azure-web-app-service

我在Windows环境下的Azure上部署了React应用程序。访问网站后出现以下错误 “您无权查看此目录或页面。”

我在根目录内添加了web.config文件,仍然出现相同的错误。

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>

1 个答案:

答案 0 :(得分:0)

遇到错误消息时,首先我们可以查看日志。有很多方法可以专门针对它。您可以在网络应用的Application Event Logs中查看Diagnose and solve problems

故障排除步骤:

  1. 首先,确认发生错误消息之前对代码文件进行了哪些更改。这可能是导致异常的原因。

  2. 检查现有程序的运行日志。建议检查相关文档或blog articles进行学习。

  3. 如果确保上述步骤正常,建议在确保程序在本地正常运行后,代码为continuously deployed through git,并在操作中检查释放状态。

(由于您当前的错误消息,我可能看了一下,这应该是部署失败)