Skip to content

React App not starting in azure app service

I’ve deployed a simple react app to azure app service and it won’t start:

How do I get the app to run index.html?

enter image description here

Answer

If you deployed to a Node Linux Web App the default document would be hostingstart.html located in /home/site/wwwroot/.

According to this:

When you create a Node.js app, by default, it’s going to use hostingstart.html as the default document unless you configure it to look for a different file. You can use a JavaScript file to configure your default document. Create a file called index.js in the root folder of your site

So go to your ssh terminal, navigate to /home/site/wwwroot. Create index.js there with the following code:

var express = require('express');
var server = express();
var options = {
index: 'index.html'
};
server.use('/', express.static('/home/site/wwwroot', options));
server.listen(process.env.PORT);

NOTE: Be sure to run npm install –save express also in this folder else your app service will crash on startup

Restart, it will configure index.html as the default document for your app.