【发布时间】:2019-11-12 19:37:47
【问题描述】:
我已在 Windows Server 上将 Angular 应用程序部署到 IIS,但由于脚本/样式包都给出 404 错误而无法加载。我在 IIS 中将我的应用程序设置为“门户”,并在 web.config 中完成了 URL 重写:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="AngularJS Routes" 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="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/portal" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
并将 index.html 上的基本 url 设置为:
<base href="/portal">
当我将应用程序构建到 dist 文件夹时,我使用的命令只是一个简单的构建 ng b,没有任何选项。
我在控制台中遇到的错误示例如下:
GET http://wavemaker.webdevelopwolf.com/inline.bundle.js net::ERR_ABORTED 404 (Not Found)
【问题讨论】:
-
所以实际文件位于
http://wavemaker.webdevelopwolf.com/portal/inline.bundle.js? -
我的应用程序指向了包含捆绑包的文件夹