IIS下部署VUE项目之API url rewrite配置 (反向代理)
Request URL:
http://47.100.118.29/xxxx-xxxxxapi/sys/randomImage/1629428467008?_t=1700619432578
Request Method:
GET
Status Code:
404 Not Found
Remote Address:
47.100.118.29:80
Referrer Policy:
strict-origin-when-cross-origin
Response Headers (4)
Request Headers
Network Log Row Name: 1629428467008?_t=1700619432578/xxxx-xxxxxapi/sys/randomImage

^(.*?)xxxx-api(.*)$ http://xxx.xxx.xxx.xxx:xxx/xxxx-api{R:2}

以上参考:https://blog.csdn.net/weixin_43721856/article/details/128248201
本次尝试iis最终配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="404" patternSyntax="ECMAScript">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" pattern="^(.*?)xxx-api(.*)$" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
<rule name="api">
<match url="^(.*?)xxx-api(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="http://xxx.xxx.xxx.xxx:xxx/xxx-api{R:2}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
20231220再次遇到IIS vue 调用api的问题,缺少了以下的一项配置,导致时间浪费了差不多2个半小时
