我在 Express 网站上遇到问题,该网站使用 SVG 和字体等其他文件。
本地运行应用程序时没有任何问题,但部署到 Azure 上后,SVG 和字体不再出现。
创建了一个web.config
项目根目录下的文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".woff" mimeType="application/x-woff" />
<mimeMap fileExtension=".ttf" mimeType="application/x-woff" />
</staticContent>
</system.webServer>
</configuration>
也使用了这个解决方案:(windows azure 中的 Svgs 和其他 mime 类型 https://stackoverflow.com/questions/11622376/svgs-and-other-mime-types-in-windows-azure)
两种解决方案现在都允许加载 SVG 文件,但不再加载网页。(HTTP 500)
看来它会覆盖配置动态内容.
应如何配置动态内容以使应用程序再次运行?
我发现了问题。
使用这个解决方案:(windows azure 中的 Svgs 和其他 mime 类型 https://stackoverflow.com/questions/11622376/svgs-and-other-mime-types-in-windows-azure)
And in 动态内容重写规则, 替换server.js
by app.js
,这是 Express 创建的默认入口点。
最终结果是:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".woff" mimeType="application/x-woff" />
<mimeMap fileExtension=".ttf" mimeType="application/x-woff" />
</staticContent>
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="DynamicContent">
<match url="/*" />
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)