Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 735
Kevin Choi Avatar asked Jun 27 '16 11:06

Kevin Choi


2 Answers

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.

like image 104
banan3'14 Avatar answered Nov 13 '22 11:11

banan3'14


While you are serving Please make sure you are serving an entire folder and not a file. For example : NOT RIGHT

http-server "/home/ubuntu/sandbox/basicserver/index.html"

But RIGHT:

http-server "/home/ubuntu/sandbox/basicserver/"

like image 5
Sagiruddin Mondal Avatar answered Nov 13 '22 12:11

Sagiruddin Mondal