gpt4 book ai didi

azure - 如何将基于 browserHistory 的 React 应用程序部署到 Azure 应用服务?

转载 作者:行者123 更新时间:2023-12-02 07:12:30 24 4
gpt4 key购买 nike

我正在将 React 应用程序部署到使用非哈希 URL(例如 browserHistory)的 Azure 应用服务,例如

http://mywebapp.azurewebsites.net/map/50.9375/6.9603/13

但是所有路径都应该由相同的index.html 处理。如何在 Azure 应用服务中完成此任务?基本上,我希望针对应用程序服务的所有请求都映射到/index.html 并让 React 解决它。

最佳答案

在部署到 Azure 应用服务的应用程序的根目录中添加 web.config 文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="redirect all requests" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="/index.html" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

关于azure - 如何将基于 browserHistory 的 React 应用程序部署到 Azure 应用服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37489691/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com