The linux app service is configured with a Node 18 LTS stack and a startup command that’s set to:
pm2 serve /home/site/wwwroot --no-daemon --spa
The --spa
tag is supposed to make all routes fallback to index.html which is not the case when accessing an url directly, a 404 error is fired. But when using the root domain, the Angular routing works correctly.
2
Answers
I have deployed the Angular app to Azure Linux App service.
Configuration
=>General Settings
=>Startup Command
, thestart up
command varies based on the type of deployment.Local Git
then the Startup Command has to beLocally , when we run the command
ng build
, dist folder will be created in the project root directory.My Configuration
The option to set
Default Documents
is available only forWindows App Service Plan
.Thanks @Huw O. Roberts for the Default document script.
For Linux App Service by default
node.js
app treatshostingstart.html
as the default document. If we want to change the default document, use the below code in yourapp.js
orindex.js
file.Referenecs taken from tutorials
When I deployed an Angular application on "Azure Linux App service" I experienced the same problem.
I added this attribute to the angular route to ignore this issue.
You can get more details from this answer 404-error-angular
We hope that Azure will provide a configuration to "Azure Linux App service" like what they did when deploy on "Azure Static Web Apps" by add "staticwebapp.config.json"
You can find more details here 404-error-azure-static-web-app