Error when serving npm http-server through terminal. (Error 404)

Kevin Choi picture Kevin Choi · Jun 27, 2016 · Viewed 8.9k times · Source

I have been trying to run a local http server for my HTML files after figuring out that the problem I was having with ng-view is that chrome does not support cross origin requests due to security reasons. Hence, I downloaded the npm http-server and tried running my html code and I get the error message:

Starting up http-server, serving indexTemplate.html
Available on:
  http://127.0.0.1:8080
  http://172.27.88.21:8080
Hit CTRL-C to stop the server
[Mon Jun 27 2016 19:48:11 GMT+0900 (KST)] "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36"
[Mon Jun 27 2016 19:48:11 GMT+0900 (KST)] "GET /" Error (404): "Not found"

Can anyone help me in figuring out what the problem is and how I can solve it? Any suggestions and help would be much appreciated!

Answer

banan3'14 picture banan3'14 · May 25, 2018

Try to run just http-server without indexTemplate.html as a parameter, in the folder where you only have indexTemplate.html and it should work just fine.