4

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.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Siva Kumar S
  • 409
  • 1
  • 6
  • 21

4 Answers4

4

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/

phoneynk
  • 110
  • 7
0

you will see something like this

"http-server -a localhost -p 5000"
Sanjay kumar
  • 1,653
  • 12
  • 18
0

It worked for me by navigating to: http://127.0.0.1:8080/index.html

JohnDoh
  • 1
  • 1
0

Downgrading to http-server 0.9.0 fixed it for me.

npm install -g http-server@0.9.0
Kamlesh Kumar
  • 1,632
  • 2
  • 21
  • 31