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"
            ],
5
  • When you run ng build, where exactly is the msal2.html file placed? Commented May 13, 2022 at 15:40
  • after I build, msal2.html is in dist/<projectname>/assets/static folder. Commented May 13, 2022 at 16:19
  • Can you not just put it in the root instead of in the assets folder..? Commented May 13, 2022 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 Commented May 14, 2022 at 8: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? Commented May 14, 2022 at 9:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.