具有localhost:3000的http服务器给出ERR_INVALID_REDIRECT

Mar*_*ill 6 windows node.js

我已经使用以下命令安装了http-server:

npm i -g http-server

运行服务器后,我得到响应说 Running on 127.0.0.1:8080

我的电话看起来像这样:

http-server -a 0.0.0.0 -c-1

如果我去127.0.0.1:808010.1.1.72:8080得到:

This page is not working.

127.0.0.1:8080 sent an invalid response

ERR_INVALID_REDIRECT

我到处搜索和搜索,实际上没有什么答案。我不使用XAMPP或IIS只是一个空白节点服务器。

Node.js: 11.12.0

npm: 6.7.0

OS: Windows 10

我已经检查了我的主机文件。那里没有相关的东西。我不知道是什么原因造成的。我也不使用.htaccess文件或Web.config文件。

如果您需要更多信息,请告诉我。

笔记

如果我去,localhost:8080/index.html我可以去我的应用程序。虽然这不应该那样工作。

MAN*_*EET 16

尝试将http服务器版本降级,因为最新版本(0.10.0和0.11.0)由于狂喜(3.3.2)导致出现问题。

尝试卸载当前的http服务器版本,然后尝试安装0.9.0或更早版本

卸载

 npm uninstall -g http-server
Run Code Online (Sandbox Code Playgroud)

安装

npm install http-server@0.9.0
Run Code Online (Sandbox Code Playgroud)


Chr*_*ney 8

http-server仍然是一个未解决的问题,它可能是由一个称为ecstatic的http-server依赖关系的最新版本引起的:

https://github.com/http-party/http-server/issues/525

目前,有三种解决方法:

  1. 将浏览器指向localhost:8080 / index.html而不是http:// localhost:8080

  2. 将您的http服务器版本从10.0降级到0.9

    npm卸载-g http-server
    npm安装http-server@0.9.0

  3. 在http-server模块下打开package.json文件,并将狂喜的依赖降级
    到3.3.1(位于“ dependencies”键下)。


Gar*_*rry -2

创建服务器时传递 url“0.0.0.0”,然后尝试。