Skip to content

Instantly share code, notes, and snippets.

@avinmathew
Created October 7, 2017 09:21
Show Gist options
  • Save avinmathew/6120a4bf5da575058355fd636e62fbc1 to your computer and use it in GitHub Desktop.
Save avinmathew/6120a4bf5da575058355fd636e62fbc1 to your computer and use it in GitHub Desktop.
React and Node.js on Azure App Service/IIS
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="server/server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="Static Assets" stopProcessing="true">
<match url="([\S]+[.](html|htm|svg|js|css|png|gif|jpg|jpeg))" />
<action type="Rewrite" url="client/build/{R:1}"/>
</rule>
<rule name="Index" stopProcessing="true">
<match url="^$" />
<action type="Rewrite" url="client/build/index.html"/>
</rule>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="api/" negate="true" />
</conditions>
<action type="Rewrite" url="client/build/index.html" />
</rule>
<rule name="API">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="server/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