Getting a 404 on refresh with an Angular app deployed on Azure Linux App Service

Discussão em 'Angular' iniciado por ncodes, Janeiro 17, 2025.

  1. ncodes

    ncodes Guest

    I have an Angular app that calls a .NET 6 BAckend. I've deployed this on a Linux App Service over at Azure.

    I'm using HashLocationStrategy in my Routing Module:

    providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}]


    This however adds a '#' on my url. I would like to remove this. So I have used PathLocationStrategy

    providers: [{provide: LocationStrategy, useClass: PathLocationStrategy}]


    This works fine on my local as I can navigate between pages of my web app and hit refresh. All good.

    The issue is that when I deployed my web app on Azure Linux Web App. As soon as I navigate away from my home page and hit refresh, I get a "404 Not Found" Error.

    I understand that this is because I am using Angular which is a SPA.

    Does this have something to do with the Linux Web App Service that I am using? How do I get around this?

    I have the below as a startup command on my release pipeline and portal configuration

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


    A lot of suggestions appear to have a web.config with rewrite rules but I don't think that'll help me as I am using a Linux Web App.

    Continue reading...

Compartilhe esta Página