http-party / http-server

a simple zero-configuration command-line http server
MIT License
13.65k stars 1.5k forks source link

ERR_INVALID_REDIRECT when running http-server #525

Open matpl opened 5 years ago

matpl commented 5 years ago

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

matpl commented 5 years ago

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 commented 5 years ago

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

matpl commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

matpl commented 5 years ago

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 commented 5 years ago

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

captainturtle commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

captainturtle commented 5 years ago

Possibly related to ecstatic issue as mentioned:

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

charlie-collard commented 5 years ago

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

gdurazzo commented 5 years ago

@bspammer I did the same and solved it too.

SCLeoX commented 5 years ago

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 commented 5 years ago

Can confirm this bug still exists.

mikeycooper commented 5 years ago

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 commented 5 years ago

Getting the same issue.

ghost commented 5 years ago

Same here, exactly as @captainturtle described it.

thornjad commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

humphd commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

phtwo commented 5 years ago

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

blackr1234 commented 5 years ago

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 commented 5 years ago

Is there any solutions, I got the same issues,

elainema commented 5 years ago

http://localhost:8080/index.html

This way can works ~~~

blackr1234 commented 5 years ago

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

m-ahmadi commented 5 years ago

Same issue here. node v8.11.3 npm v6.9.0 http-server v0.11.1

blackr1234 commented 5 years ago

@SJB250 It's because no redirection took place as you specified the file name. This issue is all about using /. No one on earth types /index.html when he or she visits a website, e.g. www.apple.com/index.html.

najibsa3d commented 5 years ago

I had the same issue, only wanted to run a server locally for js/html files, I downloaded live-server (npm install live-server -g) and the issue was fixed

ghost commented 5 years ago

Thanks, I appreciate the info. That is all I need it for too.

On Sat, May 25, 2019 at 10:46 AM Najib Saad notifications@github.com wrote:

I had the same issue, only wanted to run a server locally for js/html files, I downloaded live-server (npm install live-server -g) and the issue was fixed

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/indexzero/http-server/issues/525?email_source=notifications&email_token=AE4TKR6YYBVUICD3L3U7Z3TPXFNNNA5CNFSM4HKUWQOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWHUFVY#issuecomment-495928023, or mute the thread https://github.com/notifications/unsubscribe-auth/AE4TKR7S4WTK67XCPVQYP43PXFNNNANCNFSM4HKUWQOA .

blackr1234 commented 5 years ago

@najibsa3d Live-server works, thanks!

SkaceKamen commented 5 years ago

This is caused by ecstatic@3.2.2, works normally with ecstatic@3.2.1.

Installing ecstatic@3.2.1 fixes this issue, but 3.2.2 contains a security fix: https://www.npmjs.com/advisories/830 so downgrading this dependency will work, but I wouldn't advise it unless you're using the server for development purposes only (which is probably the main use case of this package anyway)

blackr1234 commented 5 years ago

@SkaceKamen Thank you for the information. May I know which server package should I use for production? Could you recommend one? Thanks a lot.

XinLiu1223 commented 5 years ago

using " http://localhost:8080/index.html " solved " ERR_INVALID_REDIRECT " problem

if it is a SPA such as working with react router, is still doesn't work in this way by adding index.html ...

Ali8484 commented 5 years ago

I used ( npm install http-server@0.9.0 ) ... that solved the problem for me . Have Any one more professional solution ?

watchingon9 commented 5 years ago

http-server@0.11.1 ecstatic@3.3.2 same issue exists (ERR_INVALID_REDIRECT)

Xmader commented 5 years ago

It a problem with regard to ecstatic. I fixed it in https://github.com/jfhbrook/node-ecstatic/pull/261 .

huangliu commented 5 years ago

I used ( npm install http-server@0.9.0 ) ... that solved the problem for me . Have Any one more professional solution ?

no error with 0.9.0

qtiki commented 5 years ago

It a problem with regard to ecstatic. I fixed it in jfhbrook/node-ecstatic#261 .

@Xmader I have a feeling that your pull request will never be accepted. See this: https://github.com/jfhbrook/node-ecstatic/issues/259

Here's the key quote from the very long text: "I will not accept patches or push updates to ecstatic going forward. This includes security updates."

Since you know what the issue is do you think you could do a workaround directly to the http-server package? If not then I think the only way to fix this is to set the ecstatic dependency in the package.json to an exact version that still works - which is 3.2.1 according to earlier comments.

Xmader commented 5 years ago

Here's the key quote from the very long text: "I will not accept patches or push updates to ecstatic going forward. This includes security updates."

That's a pity. Or we can create a fork and continue maintaining it.

priyal85 commented 5 years ago

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.

Can someone tell me how to down grade the ecstatic version for the already installed http-server? I'm new to npm

blackr1234 commented 5 years ago

@priyal85, just edit package.json and add an entry with a older version of ecstatic. I'm using live-server now coz it just works.

priyal85 commented 5 years ago

@priyal85, just edit package.json and add an entry with a older version of ecstatic. I'm using live-server now coz it just works.

@blackr1234 Thanks! I did this and still get the same error. After changing the package.jsaon do I have to run any command to update it

blackr1234 commented 5 years ago

@priyal85, I think I run a "npm install" under the project folder after updating package.json. It's the command you should always run after updating package.json. IIRC, I tried ecstatic v3.0.0 and it worked as mentioned by some other developers above.

docluv commented 5 years ago

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

yes, I manually changed the http-server reference to be 3.0.0 and restarted.

docluv commented 5 years ago

you can also change the estatic dependency to just * and it will grab the latest version. That also seems to be working for me.