proxy-agents icon indicating copy to clipboard operation
proxy-agents copied to clipboard

Enable localAddress

Open lukekarrys opened this issue 1 year ago • 5 comments

  • [ ] add test

lukekarrys avatar Mar 31 '24 20:03 lukekarrys

🦋 Changeset detected

Latest commit: 8c4833d9d641cea233b51100c8ce1238f21271dd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
proxy Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Mar 31 '24 20:03 changeset-bot[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
proxy-agents ✅ Ready (Inspect) Visit Preview Mar 31, 2024 8:01pm

vercel[bot] avatar Mar 31 '24 20:03 vercel[bot]

Sorry if this is the wrong place to ask this, but I'm interested in the functionality of this PR.

I managed to define the outgoing interface for requests via CLI, but I wanted to do this via code.

Could you tell me how to do this?

erickythierry avatar Mar 31 '24 20:03 erickythierry

You can set localAddress on the server returned from createProxy:


import * as http from 'http';
import { createProxy } from 'proxy';

const server = createProxy(http.createServer());
server.localAddress = LOCALADDRESS;
server.listen(3128, () => {
  var port = server.address().port;
  console.log('HTTP(s) proxy server listening on port %d', port);
});

lukekarrys avatar Mar 31 '24 20:03 lukekarrys

You can set localAddress on the server returned from createProxy:


import * as http from 'http';
import { createProxy } from 'proxy';

const server = createProxy(http.createServer());
server.localAddress = LOCALADDRESS;
server.listen(3128, () => {
  var port = server.address().port;
  console.log('HTTP(s) proxy server listening on port %d', port);
});

Thank you very much, I was looking for this

erickythierry avatar Mar 31 '24 21:03 erickythierry