0

I have rather weird issues. I did a prod build of my Angular PWA, and deployed it to hosting space. The file/folder structure of the hosting page is like this. enter image description here

The public_html has a simple HTML page and my PWA app is under public_html folder. I try to access the PWA by this URL https://example.com/pwa and my PWA doesn't load, which I figured out by looking at the missing files the url enter image description here

All the URLs have this path https://example.com/runtime.0e49e2b53282f40c8925.js, https://example.com/manifest.webmanifest and so on.

I am trying to understand how did it change to the root (public_html) whereas it should be PWA. the base href in the angular app is "/" . Where do I need to configure in PWA so that my urls which the app needs, appear like this https://example.com/pwa/manifest.webmanifest

The idea was to have a simple static landing page and a clickable link fomr the landing page to the PWA app inside the PWA folder.

Arun-
  • 846
  • 3
  • 22
  • 41
  • Where is your `index.html` located? Why do you have the `pwa` folder, what's in there? Did you use `ng add @angular/pwa`? Did you set ``? – Pieterjan Oct 15 '21 at 17:14
  • my index.html is at the root (public_html), index.html is like a static landing page, that's not a part of Angular PWA. My idea was to have an static landing page, with a link to PWA app, hence I created the folder PWA and put the app inside. And Yes, I did try base href ="/pwa" but that dosen't change the urls for the scripts – Arun- Oct 15 '21 at 17:21
  • Can you confirm that the `pwa` folder also contains an index.html, the one generated by the angular build? That's the file that needs to contain `` – Pieterjan Oct 15 '21 at 17:31
  • yes it does all have the files, although i have removed the and reverted to since having pwa didn't make any difference. – Arun- Oct 15 '21 at 17:38
  • 1
    [According to this link](https://stackoverflow.com/questions/51182322/whats-the-difference-between-base-href-and-deploy-url-parameters-of-angular) you MUST pass the `--base-href /pwa/` parameter to `ng build`. Did you do this too? – Pieterjan Oct 15 '21 at 18:18
  • that worked! thanks a lot! can you make this as an answer so that I can upvote and it can help other folks as well. – Arun- Oct 16 '21 at 11:23

1 Answers1

2

According to this link you MUST pass the --base-href /pwa/ parameter to the ng build command.

Pieterjan
  • 2,738
  • 4
  • 28
  • 55