0

I used ng build --prod to product ethe dist folder locally then I created a storage account in azure and turned on "Static App" Then I uploaded the contents of dist/xxx folder to $web folder but when I navigate to any route I get

[![enter image description here][1]][1]

things I tried

  1. set $web to blob(anonymous) access
  2. added file staticwebapp.config.json at same level where package.json is and build and uploaded the files again to container
  3. used routes.json file

for staticwebapp.config files i used following

   {
"navigationFallback": {
"rewrite": "/index.html",
"exclude": ["/images/*.{png,jpg,gif}", "/css/*"]
}
}

and

{
"navigationFallback": {
"rewrite": "index.html",
"exclude": ["/images/*.{png,jpg,gif}", "/css/*"]
}
}

and

{
"navigationFallback": {
 "rewrite": "index.html"
}
}

Normally when others having similar issue they are able to navigate to a page and when they refresh they see this problem. but in my case i get this error as soon as i navigate first. [1]: https://i.stack.imgur.com/EqV2L.png

Raas Masood
  • 99
  • 12

1 Answers1

2

According to the Microsoft Documentation,

_routes.json that was previously used to configure routing is deprecated. Use staticwebapp.config.json as described in this article to configure routing and other settings for your static web app.

Fallback routes:

Example code that returns /index.html for all static file requests.

{ 
"navigationFallback": { 
"rewrite": "/index.html" } 
}

The Example configuration file from the MS Documentation.

For further information look the similar issue fixed here.

RajkumarPalnati
  • 541
  • 2
  • 6
  • already used it as mentioned in the question but didnt worked. – Raas Masood Jul 15 '22 at 14:33
  • You can also use this [video tutorial](https://learn.microsoft.com/en-us/shows/azure-tips-and-tricks-static-web-apps/how-to-configure-routing-in-azure-static-web-apps-6-of-16--azure-tips-and-tricks-static-web-apps) from Microsoft if that is a preferred medium for you. As for the original post, it looks like they may have just been missing the `.json` suffix on their configuration file. The file should be `staticwebapp.config.json` – BasicExp Apr 03 '23 at 01:39
  • Having `.json` or not made no difference for me ... neither solved the issue. – Aiden Dipple Sep 03 '23 at 00:14