kube kube -4 years ago 171
Node.js Question

Express NodeJS web.config in Azure for SVG & Fonts

I had a problem in an Express NodeJs website I make where I use SVG and other files like Fonts.

When I ran the app locally I didn't have problem. But when I had to put it on Azure, all files like SVG and Fonts did not appear anymore.

I created a web.config file at root of project :

<?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>


Also did as they told here (Svgs and other mime types in windows azure)

Both solutions permit me to access SVG files, but the problem is that now I am not able to see my webpages ! (HTTP 500)

It seems it overrides configuration for dynamic Content.
What sould I do to configure dynamic Content to work again ?

Answer Source

I found the problem.

Used this solution: (Svgs and other mime types in windows azure)

But in Dynamic Content Rewrite Rule, replaced server.js by app.js, which is the default entry point created by Express.

Final result is:

<?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>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download