Skip to content

Instantly share code, notes, and snippets.

@tagr
Created September 28, 2014 19:12
Show Gist options
  • Save tagr/38ef0c3ced0cac53cb1e to your computer and use it in GitHub Desktop.
Save tagr/38ef0c3ced0cac53cb1e to your computer and use it in GitHub Desktop.
When you create an Express site from Microsoft Azure's gallery, it includes some default setup in a web.config. I have some code adding Expires headers for content in my /images directory. I commented a Rewrite rule in web.config so server.js can handle the static assets correctly.
<configuration>
<system.webServer>
<rewrite>
<rules>
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<!--<action type="Rewrite" url="public{REQUEST_URI}"/>--> <!--Comment this to let Node handle your static files -->
<action type="Rewrite" url="server.js"/>
</rule>
<!-- All other URLs are mapped to the Node.js application entry point -->
<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment