我在我的IIS服务器上使用url重写通过"build“进行部署,但我注意到应用程序没有加载。
我的Reactjs应用程序包装在express节点中。
这是未加载的应用程序的url:http://booleandev.com/expense-tracker
这是加载http://booleandev.com:9000的应用程序的url
我注意到应用程序没有加载的原因是因为所有的链接都链接到一个断开的链接- booleandev.com/static/...
我该如何解决这个问题。
谢谢。
发布于 2020-09-07 17:49:47
尝试使用公共路径:
const publicPath = '/path/to/subfolder/';
export const routeCodes = {
HOME: publicPath,
SEARCH: `${ publicPath }search`,
ABOUT: `${ publicPath }about`,
};
// Then you can use them like this
// <Route exact path={ routeCodes.ABOUT } component={ About } />和react-router规则:
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<add input="{DOCUMENT_ROOT}{URL}" matchType="IsFile" ignoreCase="false" />
<add input="{DOCUMENT_ROOT}{URL}" matchType="IsDirectory" ignoreCase="false" />
</conditions>
<action type="None" />
</rule>
<!--# Fallback all other routes to index.html-->
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^" ignoreCase="false" />
<action type="Rewrite" url="/path/to/subfolder/index.html" />
</rule>
</rules>
</rewrite>参考链接:
https://stackoverflow.com/questions/63769158
复制相似问题