React router direct links not working on Azure Web App Linux

后端 未结 1 941
南笙
南笙 2020-12-21 11:00

I\'ve developed an PoC about PWA (Progressive Web Apps) using ReactJs to show how to use camera, geolocation, microphone, light sensors and etc from Browser API.

I\'

相关标签:
1条回答
  • 2020-12-21 11:37

    After a little more research I found the problem. As Linux Azure Web Apps uses pm2 to serve a node app I found the answer looking into the official documentation.

    PM2 is a daemon process manager that will help you manage and keep your application online. Getting started with PM2 is straightforward, it is offered as a simple and intuitive CLI, installable via NPM.

    https://pm2.keymetrics.io/docs/usage/pm2-doc-single-page/#serving-spa-redirect-all-to-indexhtml

    Just need to add the --spa option into the Startup Command on Azure Web Apps Linux General Settings:

    pm2 serve /home/site/wwwroot/build --no-daemon --spa
    

    Using --spa option pm2 will automatically redirect all queries to the index.html and then react router will do its magic.

    0 讨论(0)
提交回复
热议问题