0

I would like to show a static HTML file as part of the Angular app, so included it in assets section in angular.json file. But still when accessing it http://localhost:4200/msal2.html via the browser, the angular routing tries to resolve it and shows the "Error: Cannot match any routes. URL Segment..". I am using Angular v12 on windows.

If I access that static html page as http://localhost:4200/assets/msal2.html, then the response is the html content present in the index.html in the angular app, not the content of my static html file.

I have referred similar questions in SO, but not finding relevant solutions. Q1, Q2.

What am I missing? is it only possible by creating a component that can show this static html content, as shown in this SO answer?

The below is the assets section in the angular.json file,

        "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/static/msal2.html"
            ],
Anand Sowmithiran
  • 2,591
  • 2
  • 10
  • 22
  • When you run `ng build`, where exactly is the `msal2.html` file placed? – JSON Derulo May 13 '22 at 15:40
  • after I build, msal2.html is in `dist//assets/static` folder. – Anand Sowmithiran May 13 '22 at 16:19
  • Can you not just put it in the root instead of in the assets folder..? – MikeOne May 13 '22 at 16:42
  • Then you need to access the file via URL `http://localhost:4200/assets/static/msal2.html`. Alternatively you can specify your asset as object, giving you further config options, see [docs](https://angular.io/guide/workspace-config#asset-config) – JSON Derulo May 14 '22 at 08:35
  • Already tried accessing that path, doesn't work - response is html content from index.html, anything to do with defining `base` path or any addition to the `route` configuration to be done? – Anand Sowmithiran May 14 '22 at 09:24

0 Answers0