Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy Angular on Azure with static website fallback problem

I'm trying to deploy my Angular app to the Azure static websites. I configured the environment following this tutorial: Medium tutorial for Azure static websites

The problem that I have is the fallback in the case I try to access for example myurl.com/mypage (with only myurl.com is working correctly).

I'm building Angular with ng build --prod.

As it's running on IIS, I've tried the following web.config: web.config, I put it in /src folder and I've changed angular.json as follows:

"assets": [
     ...
     "src/web.config"
],

and it's placing the file in the root folder which is correct.

My problem is that I'm still getting 404 when I try to access myurl.com/mypage

like image 242
NikNik Avatar asked Oct 30 '25 02:10

NikNik


1 Answers

You can specify your fallback route by creating a file called routes.json in src/assets. It should contain:

{
  "routes": [
    {
      "route": "/*",
      "serve": "/index.html",
      "statusCode": 200
    }
  ]
}
like image 173
davidfmatheson Avatar answered Nov 02 '25 23:11

davidfmatheson