React App not starting in azure app service

前端 未结 5 1376
天命终不由人
天命终不由人 2020-12-10 18:00

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?

5条回答
  •  心在旅途
    2020-12-10 18:39

    Go to Azure Configuration>General Settings

    • If your build folder is at the root of the project

    Start up command: pm2 serve /home/site/wwwroot --no-daemon --spa

    • If your build folder is inside your client folder, just add the path

    Start up command: pm2 serve /home/site/wwwroot/client/build --no-daemon --spa


    Note:

    Make sure your using Azure App Service linux server.

    I added --spa add the end to fix the issue of react-router redirect, Using --spa option pm2 will automatically redirect all queries to the index.html and then react-router will do its magic.

提交回复
热议问题