Svgs and other mime types in windows azure

Hi, I am creating a site in nodes on windows azure and would like to enable svg as background images. How can I resolve svgs and mimetypes in general?

+3
source share
2 answers

Azure uses IISNode

I added this web.config file to get svgs working. It can be changed for other mime types.

<?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>
+6
source

If Node is serving the file, just feed it to the correct MIME type (using any library you use). If you use IIS to submit the file, you need to add the MIME type to your web.config.

0
source

All Articles