【发布时间】:2017-02-06 05:53:04
【问题描述】:
我已经全局安装了http-server。
我从本地端口 8080 上的 myDir 启动它。在 myDir 我有 index.html。
如果我(从浏览器)请求http://localhost:8080/,我会得到 index.html,这没关系。
如果我通过http://localhost:8080/anything 请求,我没有得到服务器的任何响应。
相反,我想要的是我的服务器总是以 index.html 响应任何到达 localhost 端口 8080 的 http 请求。
这可能吗?
提前致谢
【问题讨论】:
-
-P or --proxy Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com=> 你能试试http-server -P http://localhost:8080/吗? -
my answer 中的解决方案对您有用吗?
-
有类似的问题,但我希望我的 dist 将作为 127.0.0.1:8080/myprofile 当我刷新这将丢失时这将如何可能。
标签: node.js httpserver