'Flutter web: Opening direct URL navigation working on local but not after deployment

I am trying to implement Flutter web url navigation in my application. When I am trying to open http://localhost:7357/privacy-policy directly it is opening fine on my local machine but when I am trying to open the same URL directly after deploying it on server it is not loading and throwing me errors. enter image description here I am using Firebase to deploy my application.

Everything works fine after deploying when I am trying to access through the home page without any specific navigation for ex: www.example.com, the error comes when I am trying to directly access the page www.example.com/privacy-policy instead of going through home page.

Any help is much appreciate. Thanks.



Solution 1:[1]

try adding "rewrites" in your firebase.json

"hosting": {
  "rewrites": [ {
    "source": "**",
    "destination": "/index.html"
   } ]
}

and refer to this: When I refresh my website I get a 404. This is with Angular2 and firebase

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 etainclub