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

ERR_INVALID_REDIRECT when running http-server

Open matpl opened this issue 5 years ago • 139 comments

Do you want to request a feature or report a bug?

If the issue is a bug report, please provide the steps to reproduce it. Please include the actual command causing the issue if applicable.

npm i -g http-server http-server

Then open chrome at 127.0.0.1:8080

What did you expect to happen?

Open an empty page

What actually happened? Please include the actual error trace and / or stack trace if applicable.

ERR_INVALID_REDIRECT

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

Tell us about your environment

  • http-server version: Tried 0.11 and also the master branch from the github repo
  • Platform: win10

matpl avatar May 03 '19 15:05 matpl

I feel it may be related to the ecstatic issue earlier today... Could it be possible that the updated version of ecstatic (3.3.2) isn't compatible with http-server?

matpl avatar May 03 '19 15:05 matpl

What is in the directory you're serving? I'm not getting the same on my Mac

thornjad avatar May 03 '19 16:05 thornjad

I'm serving the current directory. I tried with an index.html with an empty body, but I still get ERR_INVALID_REDIRECT. I'm at work so it could possibly be a proxy issue or something. I can try again at home later today to see if I get the same behavior.

matpl avatar May 03 '19 17:05 matpl

I have the same issue. I'm running http-server on Windows 10, and getting the same error. I updated http-server and ecstatic, but it didn't work. In my case I only have a single html page (index.html).

captainturtle avatar May 03 '19 17:05 captainturtle

Just an idea, but do any of you see the same thing if you use npx http-server-legacy instead of http-server?

thornjad avatar May 03 '19 18:05 thornjad

I have the same issue with npx http-server-legacy. And I use http-server on a weekly basis I'd say, and I only had this error from a fresh install for http-server. So it was working fine with the latest version in the last weeks, and it stopped working after a clean install today (with the same version). That's why I suspect a dependency issue.

matpl avatar May 03 '19 18:05 matpl

i have the same issue, both http-server and http-server-legacy, no solution so far

gdurazzo avatar May 03 '19 18:05 gdurazzo

I think the issue is somehow related to directories.

When I enter http://localhost:8080, I get the same error, however requesting http://localhost:8080/index.html directly works.

A weird thing happens when I request a directory under the root. When I go to http://localhost:8080/folder it redirects me to this address: http://localhost:8080/folder/////////////////// and produces this error:

This page isn’t working localhost redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS

captainturtle avatar May 03 '19 20:05 captainturtle

Just an idea, but do any of you see the same thing if you use npx http-server-legacy instead of http-server?

I have tried npx http-server-legacy now, still giving the error.

captainturtle avatar May 03 '19 20:05 captainturtle

I'm having exactly the same error as @captainturtle on windows only. Seems to be working fine on OSX.

charlie-collard avatar May 03 '19 21:05 charlie-collard

Possibly related to ecstatic issue as mentioned:

https://www.npmjs.com/advisories/830

captainturtle avatar May 03 '19 21:05 captainturtle

It's definitely ecstatic. I downgraded to 3.0.0 and the issue disappears.

charlie-collard avatar May 05 '19 19:05 charlie-collard

@bspammer I did the same and solved it too.

gdurazzo avatar May 06 '19 12:05 gdurazzo

Ahhh this is so annoying. Because of this ecstatic thing, I waited 2 days before my CI gets back up again. Now my dev server is broken.

SCLeoX avatar May 06 '19 16:05 SCLeoX

Can confirm this bug still exists.

rendall avatar May 15 '19 09:05 rendall

Confirmed the issue is due to http-server being incompatible ecstatic 3.3.2. Updating http-server's package.json to require ecstatic 3.3.1 fixes http-server for me.

mikeycooper avatar May 15 '19 18:05 mikeycooper

Getting the same issue.

leptest avatar May 16 '19 09:05 leptest

Same here, exactly as @captainturtle described it.

ghost avatar May 16 '19 16:05 ghost

This seems to be caused by jfhbrook/node-ecstatic#260, which is unlikely to ever be fixed. Is anyone seeing this on a non-Windows machine?

thornjad avatar May 16 '19 18:05 thornjad

This resolv my problem

PS C:\myapp> node --version v12.2.0

PS C:\myapp> npm --version 6.9.0

PS C:\myapp> npm install -g [email protected]

tuxpedro avatar May 16 '19 19:05 tuxpedro

Just confirmed - same problem and tuxpedro's solution worked for me on Windows (version 0.9.0 of http-server which uses a much earlier ecstatic it looks like). I tried forcing ecstatic to 3.3.1 like mikeycooper, but that did not work for me.

rafikiadmin avatar May 16 '19 20:05 rafikiadmin

Same issue. My http-server was using ecstatic 3.0.0 and it was not working. @tuxpedro solution worked

aleksvatman avatar May 17 '19 09:05 aleksvatman

I've seen this happen to a dozen or so of my web students this week, and it only seems to be on Windows.

humphd avatar May 17 '19 15:05 humphd

Follow-up from one of my students, who says that using http://localhost:8080 causes the bug, but explicitly using http://localhost:8080/index.html works.

humphd avatar May 18 '19 00:05 humphd

Downgrading to http-server 0.9.0 fixed it for me under Windows

tlloydukdev avatar May 18 '19 14:05 tlloydukdev

Same issue on Windows. Downgrading to 0.9.0 or explicitly using *.html worked

phtwo avatar May 20 '19 07:05 phtwo

Same issue on Windows 10 Insider Preview 18890. I fixed it by adding ecstatic 3.0.0 entry in package.json and then npm install.

blackr1234 avatar May 20 '19 08:05 blackr1234

Is there any solutions, I got the same issues,

elainema avatar May 20 '19 11:05 elainema

http://localhost:8080/index.html

This way can works ~~~

elainema avatar May 20 '19 11:05 elainema

@elainema Of course manually appending "/index.html" will work but this is not the point of this issue. Read the "Magic Files" section documented in README.md: index.html will be served as the default file to any directory requests.

blackr1234 avatar May 20 '19 11:05 blackr1234