2012-07-24 27 views

回答

0

如果Node正在提供文件,只需使用正確的MIME類型(使用您正在使用的任何庫)來提供它。如果您使用IIS提供文件,那麼您需要將MIME類型添加到您的web.config中。

+0

我想補充參考如何MIME類型添加到IIS:http://www.iis.net/ConfigReference/system.webServer/staticContent/mimeMap – astaykov 2012-07-24 07:42:14

+0

節點當我在本地運行它時使用的文件很好(通過express使用node-mime),但是當我推到azure時,svgs未加載。 – 2012-07-24 10:08:32

+0

它發送了什麼內容類型標題? – ebohlman 2012-07-24 11:02:22

6

Azure的使用IISNode

我加入這個web.config文件來獲得svgs工作。 它可以修改爲其他MIME類型

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.webServer> 
    <staticContent> 
     <mimeMap fileExtension=".svg" mimeType="image/svg+xml"/> 
    </staticContent> 
    <handlers> 
     <add modules="iisnode" name="iisnode" path="server.js" verb="*"/> 
    </handlers> 
    <rewrite> 
     <rules> 
     <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true"> 
      <match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$"/> 
     </rule> 
     <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true"> 
      <match url="^server.js\/debug[\/]?"/> 
     </rule> 
     <rule name="StaticContent"> 
      <action type="Rewrite" url="public{REQUEST_URI}"/> 
     </rule> 
     <rule name="DynamicContent"> 
      <conditions> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/> 
      </conditions> 
      <action type="Rewrite" url="server.js"/> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration>