http-server: Proxy option leads to uncaught exception if passed without protocol
Reproduce by running:
http-server --proxy google.com
You will get an error link this:
/Users/moritzkneilmann/.config/yarn/global/node_modules/requires-port/index.js:13
protocol = protocol.split(':')[0];
^
TypeError: Cannot read property 'split' of null
at required (/Users/moritzkneilmann/.config/yarn/global/node_modules/requires-port/index.js:13:23)
at Object.common.setupOutgoing (/Users/moritzkneilmann/.config/yarn/global/node_modules/http-proxy/lib/http-proxy/common.js:101:7)
at Array.stream (/Users/moritzkneilmann/.config/yarn/global/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:127:14)
at ProxyServer.<anonymous> (/Users/moritzkneilmann/.config/yarn/global/node_modules/http-proxy/lib/http-proxy/index.js:81:21)
at Array.<anonymous> (/Users/moritzkneilmann/.config/yarn/global/node_modules/http-server/lib/http-server.js:111:13)
at dispatch (/Users/moritzkneilmann/.config/yarn/global/node_modules/union/lib/routing-stream.js:119:21)
at Object.onceWrapper (events.js:273:13)
at module.exports.emit (events.js:182:13)
at /Users/moritzkneilmann/.config/yarn/global/node_modules/union/lib/routing-stream.js:114:23
at Object.exports.(anonymous function) (/Users/moritzkneilmann/.config/yarn/global/node_modules/ecstatic/lib/ecstatic/status-handlers.js:37:5)
This is no issue if --proxy https://google.com
is used.
PS: thanks for this package; it’s an essential tool for testing for me 👍
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 19 (10 by maintainers)
Commits related to this issue
- Fixes #451 — committed to Ratcoder/http-server by Ratcoder 3 years ago
- Added test for issue #451 — committed to Ratcoder/http-server by Ratcoder 3 years ago
I have just faced a similar issue on a mac with catalina.
What is the solution for this? I tried everything. For me it’s working fine in windows PC. But not in mac. It was working fine earlier. Now it gives the error TypeError: Cannot read property ‘split’ of null. required-port