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

ERR_INVALID_REDIRECT when running http-server #525

Open
matpl opened this issue May 3, 2019 · 139 comments · Fixed by daicalong/portfolio#17 or #569 · May be fixed by #722
Open

ERR_INVALID_REDIRECT when running http-server #525

matpl opened this issue May 3, 2019 · 139 comments · Fixed by daicalong/portfolio#17 or #569 · May be fixed by #722
Labels
help-wanted high priority Very important bug or security fix

Comments

@matpl
Copy link

matpl commented May 3, 2019

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
Copy link
Author

matpl commented May 3, 2019

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?

@thornjad
Copy link
Member

thornjad commented May 3, 2019

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

@matpl
Copy link
Author

matpl commented May 3, 2019

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.

@captainturtle
Copy link

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).

@thornjad
Copy link
Member

thornjad commented May 3, 2019

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

@matpl
Copy link
Author

matpl commented May 3, 2019

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.

@gdurazzo
Copy link

gdurazzo commented May 3, 2019

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

@captainturtle
Copy link

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
Copy link

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.

@charlie-collard
Copy link

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

@captainturtle
Copy link

Possibly related to ecstatic issue as mentioned:

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

@charlie-collard
Copy link

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

@gdurazzo
Copy link

gdurazzo commented May 6, 2019

@bspammer I did the same and solved it too.

@SCLeoX
Copy link

SCLeoX commented May 6, 2019

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.

@rendall
Copy link

rendall commented May 15, 2019

Can confirm this bug still exists.

@mikeycooper
Copy link

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.

@leptest
Copy link

leptest commented May 16, 2019

Getting the same issue.

@ghost
Copy link

ghost commented May 16, 2019

Same here, exactly as @captainturtle described it.

@thornjad
Copy link
Member

thornjad commented May 16, 2019

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?

@tuxpedro
Copy link

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 http-server@0.9.0

@rafikiadmin
Copy link

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.

@aleksvatman
Copy link

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

@humphd
Copy link

humphd commented May 17, 2019

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
Copy link

humphd commented May 18, 2019

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.

@tlloydukdev
Copy link

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

@phtwo
Copy link

phtwo commented May 20, 2019

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

@blackr1234
Copy link

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.

@elainema

This comment has been minimized.

@fredlebel
Copy link

Here are a couple of screenshots from the Chrome dev tools.

http-server 0.9.0
image

http-server 0.12.3
image

@karx
Copy link

karx commented Jul 1, 2020

Fixed it for me on Window 10, by updating to latest version of http-server, i.e 0.12.3

Notes, was facing issue in http-server@0.11.1. it had ecstatic@3.3.2

Robdel12 added a commit to percy/example-percyscript that referenced this issue Aug 7, 2020
http-party/http-server#525

The `ecstatic` package has long standing issues on windows. Downgrading should
fix this issue.

In the future we should dump `http-server` for something that doen't carry so
many issues on windows
Robdel12 added a commit to percy/example-percyscript that referenced this issue Aug 7, 2020
* fix: Windows `http-server` redirect errors

http-party/http-server#525

The `ecstatic` package has long standing issues on windows. Downgrading should
fix this issue.

In the future we should dump `http-server` for something that doen't carry so
many issues on windows

* ci: Setup GitHub actions windows testing

* fix: Try v0.12.3 of `http-server`
@Shashankshekhar22
Copy link

If you look in your console, you'll see that while the install, activate, caching, and registration all happen, the "fetch" won't. This is because you located the service worker under js, so for security reasons Chrome (etc) won't use it for any URLs except those in the same directory or below.

Move your app.js file service worker level or its subdirectory level
image

@underside82173

This comment has been minimized.

@underside82173

This comment has been minimized.

@tchakabam

This comment has been minimized.

@thornjad
Copy link
Member

I've been unable to reproduce this so far, is anyone seeing this same issue with http-server v13.0.0?

@thornjad thornjad pinned this issue Aug 17, 2021
@thornjad thornjad linked a pull request Aug 17, 2021 that will close this issue
@thornjad
Copy link
Member

Alternatively, if v13.0.0 still has this problem, would anyone be able to try out the changes in #722? Since I can't reproduce, I can't check to see if that PR fixes this

@ADCJustinH
Copy link

Can confirm that 13.0.2 resolved this issue for me (Windows 10.0.19043). Thanks!

@thornjad
Copy link
Member

thornjad commented Sep 16, 2021

Thank you for checking! I'll wait and see if at least one more person can confirm (since this has been a major issue) before I close this as done and shut down #722

@thornjad thornjad unpinned this issue Oct 5, 2021
@pavelety
Copy link

You can set to open index.html by default with a script in package.json.

  "scripts": {
    "start": "http-server -o http://localhost:8080/index.html"
  },

ZanderOlidan pushed a commit to ZanderOlidan/vue-cli-service-chalkfix that referenced this issue Feb 5, 2024
Fixes Windows compatibility caused by http-party/http-server#525

And, serve is better maintained than http-server or ecstatic.
ZanderOlidan pushed a commit to ZanderOlidan/vue-cli-service-chalkfix that referenced this issue Feb 5, 2024
Fixes Windows compatibility caused by http-party/http-server#525

And, serve is better maintained than http-server or ecstatic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment