Skip to content

Proxy option leads to uncaught exception if passed without protocol #451

@MoritzKn

Description

@MoritzKn

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 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions