angularangular-pwa

Localhost throwing invalid response after running http-server for Angular PWA


I have installed PWA to my Angular application by ng add @angular/pwa and followed the all necessary steps.

To run PWA locally I have installed http-server globally by npm i -g http-server

After building production by ng build --prod, I ran http-server -o from dist folder but localhost is not working and throwing invalid response.

I have tried with different ports by http-server -p 5000 but it's not working.


Solution

  • We need to execute "http-server -o" command from dist/ and not from dist.

    Also as mentioned in https://github.com/http-party/http-server/issues/525 I had to access using http://127.0.0.1:8080/index.html instead of http://127.0.0.1:8080/