Upon the deployment of an Azure Web App, also referred to as an App Service, a couple of key actions take place:
- By default, the web app is directed to opt/startup/hostingstart.html.
- A hostingstart.html file is placed in home/site/wwwroot.
When your code is deployed, the hostingstart.html file in home/site/wwwroot is replaced. However, the web app still maintains its reference to opt/startup/hostingstart.html. This becomes evident if you remove the opt/startup/hostingstart.html file – your web app will generate a "CANNOT GET/" error.
If you wish to modify this default behavior, the process is simpler than it may seem:
- Navigate to the Configuration section of your web app.
- Integrate the following code into the startup script:
pm2 serve /home/site/wwwroot --no-daemon
By implementing this command, the web app will serve the contents of the wwwroot folder.
In the event that this web app functions as a single-page application on the client side and you're encountering challenges with routing, you can augment the above command as follows:
pm2 serve /home/site/wwwroot --no-daemon --spa
This adjustment includes the "--spa" parameter, which aids in managing routing issues.
See- https://learn.microsoft.com/en-us/azure/app-service/configure-language-nodejs?pivots=platform-linux
Let us know if further query or issue remains.