4

I had a problem in an Express website, which uses SVG and other files like fonts.

Did not have any problem when running app locally, but once deployed on Azure, SVG and fonts didn't appear anymore.

Created a web.config file at project root:

<?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 used this solution: (Svgs and other mime types in windows azure)

Both solutions now permit to load SVG files, but webpages are not loaded anymore. (HTTP 500)

It seems it overrides configuration for Dynamic Content.

How should Dynamic Content be configured to make app work again?

4

1 回答 1

9

I found the problem.

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

And 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>
于 2013-02-19T12:57:45.493 回答