How to host reactjs and nodejs web app on azure vm IIS?

Sudesh Sharma 176 Reputation points

I have created a web app with React and nodejs. Now I want to host web app on azure vm IIS web server. I have installed all necessary software i.e urlrewrite,iisnode etc.

I am confused about web.config file. How to write config file for both react js and nodejs? Can we write two rewrite rules inside one config file?

web.config file:


<add name="Access-Control-Allow-Origin" value="*" />

<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
<add value="server.js" />

<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" />
<action type="Rewrite" url="/build/index.html" />

<rule name="sendtonode">
<match url=".*"/>
<action type="Rewrite" url="server.js"/>



Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,547 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,356 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 27,026 Reputation points Microsoft Employee
    1 person found this answer helpful.
    0 comments No comments