I've scoured the web searching for a solution on how to deploy a React App on Microsoft's IIS.
I have successfully managed to deploy multiple Node.JS Applications but no such luck with React.
What I've tried:
installed URL Rewrite
I ran:
npm i -g create-react-app
I created a basic react app:
create-react-app my-app
I created a file called
web.config
in./public
route
web.config
<?xml version="1.0"?>
<configuration>
<system.webServer>
<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="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
- I then ran
npm run build
- In IIS I added a
new website
with Application Pool:DefaultAppPool
, the path linked to the./build
folder directory. - I ran browsed to the App
- I get a
Site can't be reached
Error.
Anyone else tried to deploy on IIS?
I've also tried the following resources: - https://github.com/react-boilerplate/react-boilerplate/issues/711 - https://www.quora.com/How-can-one-host-ReactJS-in-IIS - https://hackernoon.com/adding-web-config-to-react-projects-3eb762dbe01f