20

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!

5
  • 1
    So did you try to go to http://127.0.0.1:8080/indexTemplate.html Commented Jun 27, 2016 at 12:17
  • yeah it wouldn't load Commented Jun 27, 2016 at 13:16
  • 7
    Try to run just http-server without indexTemplate.html. I just try to run http-server in a folder where i only have index.html and it works just fine Commented Jun 27, 2016 at 13:30
  • Thank you! I didn't know that you just run the http-server in the folder and not the file. Works like a charm now. Commented Jun 27, 2016 at 22:30
  • Same error on Heroku Commented Oct 7, 2016 at 13:24

3 Answers 3

17

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.

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

Comments

9

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/"

1 Comment

this is the perfect answer
0

I also had the same issue with an angular app, the problem was I was running the command at the src folder

PS D:\Pub Sub Kafka\App\NotificationApp\angular-pwa-app\src> http-server -p 8080 -c-1 dist/angular-pwa-app

I got the error

This localhost page can’t be found

Then I went one folder up where the dist folder located then ran the command

PS D:\Pub Sub Kafka\App\NotificationApp\angular-pwa-app> http-server -p 8080 -c-1 dist/angular-pwa-app

and it rendered the page on http://localhost:8080/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.