title: React and Node app deployed on Azure web app shows JSON result instead of HTML page
body: <p>I have a react app with node backend. I deployed it to Azure Web app , everything works fine.</p>
  <p>When i open the url, i can see the application getting loaded and the data from the node app also getting fetched and displayed on the front end.</p>
  <p>But when the user navigates to certain routes, it shows JSON which is served by the Node backend rather than a web page that should be displayed</p>
  <p><strong>Server.JS</strong></p>
  <pre><code>import express from 'express';
  import path from 'path'
  
  import dotenv from &quot;dotenv&quot;;
  
  dotenv.config();
  
  /* Create an Express application.*/
  const app = express();
  const __dirname = path.resolve();
  app.use(express.json())
  app.use(express.urlencoded({ extended: true }))
  
  routes.forEach(route =&gt; {
      app[route.method](route.path, route.handler);
  });
  if (['production'].includes(process.env.NODE_ENV)) {
      const root = path.join(__dirname,'..', 'client', 'build')
      app.use(express.static(root));
      console.log(root);
      app.get(&quot;*&quot;, (req, res) =&gt; {
          res.sendFile('index.html', { root });
      })
  }
  const dBConnectionString = process.env.CON_STRING|| &quot;&quot;;
  const PORT = process.env.PORT || 8080;
  
  db.connect(dBConnectionString)
      .catch(err =&gt; {
          console.error(err.stack);
          process.exit(1)
      })
      .then(app.listen(PORT, () =&gt; {
          console.log(`Server is running on port ${PORT}`);
      }));
  </code></pre>
  <p>And the react app is deployed inside the <strong><code>wwwroot/site/client/build</code></strong> folder. I am using PM2 command as a startup command to run the app,</p>
  <pre><code>pm2 start ecosystem.config.js --no-daemon
  </code></pre>
  <p>and <strong>ecosystem.config.js</strong></p>
  <pre><code>module.exports = {
      apps: [{
          name: &quot;node&quot;,
          script: &quot;./server.js&quot;,
          cwd: &quot;/home/site/wwwroot/server/&quot;
      }
     ]
  }
  </code></pre>
  <p>when i access this url <code>https://web.azurewebsites.net/books/60ea9a3caffa68e153835489</code> it return a json where it should show a web page.</p>
  <p>Should i run the the node app and react app in different ports? how to configure that in pm2?</p>