Skip to content

If port can be converted to a number convert it #321

Closed
@gsf

Description

@gsf

I'd like to set up a proxy server like so:

var httpProxy = require('http-proxy');

var port = process.env.PORT || 9876;
var proxiedHost = process.env.PROXIEDHOST || '127.0.0.1';
var proxiedPort = process.env.PROXIEDPORT || 8765;

httpProxy.createServer(proxiedPort, proxiedHost).listen(port);

If I set an environment variable for PORT I'm fine but doing the same for PROXIEDPORT breaks things because it expects a number instead of a string. Looks like node handles this in the net library with a handy toNumber function.

(Also, as an aside, it would be nice if the proxied host defaulted to 127.0.0.1 when missing that parameter.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions