IIS 推送状态认为我所有的反应路线都是静态文件
IIS push state thinks all my react routes are static files
我正在按照这两个帖子尝试设置我的 IIS 以支持推送状态。
https://gist.github.com/jdmonty/8e579b3b7c19ad80b78a
但是每次我尝试访问像 localhost/app/myroute 这样的路由时,IIS 认为 myroute
是一个静态文件并且 IIS returns 一个 404
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
我在我的站点处理程序映射中发现了一个静态文件处理程序,其规则为 *
,我猜它正在处理我的请求,因为它没有扩展名。我尝试删除规则并尝试将规则编辑为 *.*
以强制扩展,但似乎都不起作用。这是我当前的网络配置重写规则
<rule name="Main Rule" 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="api.*" negate="true" />
</conditions>
<action type="Rewrite" url="/app/" />
</rule>
我在 React 路由器中结合使用 useBaseName
和在我的 index.html 文件中使用 <base href="/app">
解决了这个问题。
似乎发生的事情是我 index.html 中的所有静态资源都是没有 <base href>
设置的问题,这导致规则触发并且没有给我正确的资源。
我正在按照这两个帖子尝试设置我的 IIS 以支持推送状态。
https://gist.github.com/jdmonty/8e579b3b7c19ad80b78a
但是每次我尝试访问像 localhost/app/myroute 这样的路由时,IIS 认为 myroute
是一个静态文件并且 IIS returns 一个 404
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
我在我的站点处理程序映射中发现了一个静态文件处理程序,其规则为 *
,我猜它正在处理我的请求,因为它没有扩展名。我尝试删除规则并尝试将规则编辑为 *.*
以强制扩展,但似乎都不起作用。这是我当前的网络配置重写规则
<rule name="Main Rule" 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="api.*" negate="true" />
</conditions>
<action type="Rewrite" url="/app/" />
</rule>
我在 React 路由器中结合使用 useBaseName
和在我的 index.html 文件中使用 <base href="/app">
解决了这个问题。
似乎发生的事情是我 index.html 中的所有静态资源都是没有 <base href>
设置的问题,这导致规则触发并且没有给我正确的资源。