【发布时间】:2022-01-07 07:09:54
【问题描述】:
我正在尝试在 IIS 上部署 VUE 前端应用程序。
路由在开发模式下工作正常,但是,当我在 IIS 上托管我的 VUE 应用程序时,路由似乎中断了。
有人可以建议如何配置 IIS 来处理 VUE 前端应用程序的路由(我正在使用 vue-router)?
【问题讨论】:
标签: vue.js iis web-applications vue-router web-deployment
我正在尝试在 IIS 上部署 VUE 前端应用程序。
路由在开发模式下工作正常,但是,当我在 IIS 上托管我的 VUE 应用程序时,路由似乎中断了。
有人可以建议如何配置 IIS 来处理 VUE 前端应用程序的路由(我正在使用 vue-router)?
【问题讨论】:
标签: vue.js iis web-applications vue-router web-deployment
以下是使用正确的路由配置在 iis 服务器上部署 vue 应用程序的步骤:
设置 IIS
生成 VUE 应用文件
npm run build
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="404" path="/survey/notfound" responseMode="ExecuteURL" />
<error statusCode="500" path="/survey/error" responseMode="ExecuteURL" />
</httpErrors>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
【讨论】: