[英]Express NodeJS web.config in Azure for SVG & Fonts
我在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類型 )
這兩種解決方案現在都允許加載SVG文件,但不再加載網頁。 (HTTP 500)
它似乎覆蓋了動態內容的配置。
如何配置動態內容以使應用程序再次運行?
我發現了這個問題。
使用此解決方案:( Windows中的Svgs和其他mime類型 )
在動態內容重寫規則中 ,由app.js
替換server.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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.