Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downloads index.html instead of serving it #657

Closed
alexeychikk opened this issue Oct 10, 2020 · 12 comments
Closed

Downloads index.html instead of serving it #657

alexeychikk opened this issue Oct 10, 2020 · 12 comments

Comments

@alexeychikk
Copy link

Steps to reproduce the issue, if applicable. Include the actual command and output and/or stack trace.

http-server ./dist

What did you expect to happen?

I expected to see rendered ./dist/index.html web page in the browser.
BUT instead browser opens save file dialog.

If the issue is a feature request, what is the motivation / use case for it?

Tell us about your environment

  • exact http-server version: ^0.12.3
  • Node version: 12.16.3
  • Platform: Windows 10, Chrome 86.0.4240.75 (Official Build) (64-bit)

Other information (related issues, suggestions for a fix, etc):

@alexeychikk
Copy link
Author

Fixed prepending the command with npx like this:
npx http-server ./dist

@thornjad
Copy link
Member

@alexeychikk http-server and npx http-server should behave identically. How did you have it installed for the non-npx version?

@alexeychikk
Copy link
Author

@thornjad I installed it with npm i -D http-server

@thornjad
Copy link
Member

thornjad commented Oct 12, 2020 via email

@alexeychikk
Copy link
Author

@thornjad

PS D:\git\alexeychikk.github.io> http-server --version
http-server: The term 'http-server' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS D:\git\alexeychikk.github.io> npm run serve

> alexeychikk.github.io@1.0.0 serve D:\git\alexeychikk.github.io
> http-server --version

v0.12.3

@thornjad
Copy link
Member

Hm, odd. Well I'm not sure what happened, and I have very little experience with Windows, so I don't know if there's any Windows-specific stuff going on there. I'm glad npx works! I'm partial to using npx most of the time anyway.

@izaleu
Copy link

izaleu commented Apr 4, 2021

I have the same issue, using npx did not fix it for me.

@zm3d3ni
Copy link

zm3d3ni commented Apr 20, 2021

Try http://127.0.0.1:8080/index.html in windows

@vincentLW
Copy link

I have the same issue, using npx did not fix it for me.

try clear the cache for localhost:8080

@Cosy-harks
Copy link

I had this issue when I searched localhost:8080

Issue gone when I searched localhost:8080/index.html

@yuvalkabeli
Copy link

In case someone still has trouble (I tried everything I found online and still got stumped) I found this command:
http-server --proxy http://localhost:8080?
once I did this it opened up an HTML page with a menu for all the files in my project with each one having a separate address.
It's definitely not the best solution, but if you run out of options try it out!

@goldingdamien
Copy link

I had a similar issue where using port 8080 was causing a download of file "download" to be downloaded with the contents of the html file.
I couldn't fix it with anything here, but it was fixed by changing to port 8081.
It would be nice if someone could provide a reason for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants