http-server icon indicating copy to clipboard operation
http-server copied to clipboard

html documents served are downloaded

Open LordUber opened this issue 4 years ago • 9 comments

http-server example on this page https://stackabuse.com/how-to-start-a-node-server-examples-with-the-most-popular-frameworks/ Tell us about your environment

  • exact http-server version: 0.12.1
  • Node version: 12.16.2
  • Platform: Win10

Other information (related issues, suggestions for a fix, etc): Just learning about the server but when it goes to serve the example page it downloads it instead of displaying it. Does this in both Chrome and Firefox (latest versions). Any chance you could explain what I am doing wrong if this is my issue? Thanks.

LordUber avatar Apr 19 '20 15:04 LordUber

I can at least confirm the Firefox behavior, it's working on chrome (latest)

geommr avatar Apr 20 '20 20:04 geommr

What does the file you're trying to serve look like? Does it have the file extension .html? Do other servers serve it properly?

thornjad avatar Apr 22 '20 15:04 thornjad

index.docx Thanks for your reply. This is happening on both Chrome and Firefox. This is the code of index.html. It was originally a visual studio code template, but I added to it to see if that helped.

LordUber avatar Apr 22 '20 15:04 LordUber

index.docx

LordUber avatar Apr 22 '20 16:04 LordUber

Is the file actually called index.docx? If so, that makes it a Microsoft Word document, which should be downloaded. There isn't really any way for a regular web server to serve a file like that.

thornjad avatar Apr 27 '20 15:04 thornjad

No, I just put it into a docx file so you can see it - I couldn't upload the html file.

Thanks

On Mon, Apr 27, 2020 at 11:02 PM Jade Michael Thornton < [email protected]> wrote:

Is the file actually called index.docx? If so, that makes it a Microsoft Word document, which should be downloaded. There isn't really any way for a regular web server to serve a file like that.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/http-party/http-server/issues/623#issuecomment-620042672, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTBA4ZWTGRCPCU7MGUBC4DROWNBLANCNFSM4ML2UI5A .

LordUber avatar Apr 28 '20 08:04 LordUber

This is probably a problem with the http response header. Maybe Chrome fixes it, but firefox doesn't. If you serve a file with de content-type header 'test/html' (notice the typo!), firefox will download it.

Octalbyte avatar Nov 20 '20 11:11 Octalbyte

Seems like a duplicate of https://github.com/http-party/http-server/issues/657 . A complete list of response headers might help debugging this.

zbynek avatar Jul 14 '21 06:07 zbynek

This issue has been inactive for 180 days

github-actions[bot] avatar Jan 10 '22 12:01 github-actions[bot]