The -P flag, yes.
But the server crashes when if I try to access 127.0.0.1/something (when something is handled from client side)
stack trace:
http-server -P /
Starting up http-server, serving ./
Available on:
http://127.0.0.1:8080
http://192.168.1.115:8080
Unhandled requests will be served from: /
Hit CTRL-C to stop the server
[Sat May 13 2017] "GET /boo" "Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0"
/usr/lib/node_modules/http-server/node_modules/requires-port/index.js:13
protocol = protocol.split(':')[0];
^
TypeError: Cannot read property 'split' of null
at required (/usr/lib/node_modules/http-server/node_modules/requires-port/index.js:13:22)
at Object.common.setupOutgoing (/usr/lib/node_modules/http-server/node_modules/http-proxy/lib/http-proxy/common.js:102:7)
at Array.stream (/usr/lib/node_modules/http-server/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:120:14)
at ProxyServer.<anonymous> (/usr/lib/node_modules/http-server/node_modules/http-proxy/lib/http-proxy/index.js:80:21)
at Array.<anonymous> (/usr/lib/node_modules/http-server/lib/http-server.js:109:13)
at dispatch (/usr/lib/node_modules/http-server/node_modules/union/lib/routing-stream.js:119:21)
at g (events.js:292:16)
at emitNone (events.js:86:13)
at emit (events.js:185:7)
at /usr/lib/node_modules/http-server/node_modules/union/lib/routing-stream.js:114:23
@dumptyd as you've found, -P is not what you want. That's for proxying other endpoints and / isn't one.
Would you mind giving PR #369 a try for your use case and reporting thoughts over there?
Thanks!
馃帺
We've added the recommendation to use 404.html as the fallback URL. It prevents over catching (at multiple URLs) of a single "fallback" response, still provides the option to later create static (or server-side rendered) resources at each URL (which is far better for production environments), and still plays nice with pushState() usage.
Most helpful comment
But the server crashes when if I try to access 127.0.0.1/something (when
somethingis handled from client side)stack trace: