0

I tried to use http-server for Nodejs so I followed the step from here. URL

Once I start the server, it runs well but I cannot access the index.html page. The browser just show "This page isn’t working" message.

I am trying to use Angular's service worker and I tried to use this command.

"C:\Works\angular-pwa-app\dist>http-server -c-1 ."

and

I could see:

Starting up http-server, serving . Available on:
http://192.168.1.37:8080 http://127.0.0.1:8080 Hit CTRL-C to stop the server

When I tried to access "http://127.0.0.1:8080", the command line shows:

[Mon Jun 10 2019 14:38:23 GMT-0600 (Mountain Daylight Time)] "GET /" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36"

and then I see the fail message on browser.

what did I miss?

1
  • 1
    Please share your project structure, is there public folder in your project? Commented Jun 11, 2019 at 3:12

1 Answer 1

2

I had problem running PWA from http server in my angular 7 application.

Than i switched to angular-http-server. It works perfectly with that--

You can find it in this link--

https://www.npmjs.com/package/angular-http-server

also you are running your http-server inside dist folder. It should be

dist/your-project-name

folder if you are using version above 6.0 in angular. For version below 6 you can run the server from dist folder

For http-server with angular 7 and angular 8 you need to enable cliend side routing and that can be done with # routing --

Try imports: [RouterModule.forRoot(routes, {useHash: true})],

in your routing module. This normally solves http-server problem

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.