question

SudeshSharma-4223 avatar image
0 Votes"
SudeshSharma-4223 asked ·

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

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:

<configuration>
<system.webServer>


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

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

<rewrite>
<rules>
<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="/build/index.html" />
</rule>

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

</rules>
</rewrite>


</system.webServer>
</configuration>

azure-virtual-machinesazure-webapps-development
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ryanchill avatar image
1 Vote"
ryanchill answered ·
·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.