Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable localAddress #306

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Enable localAddress #306

wants to merge 2 commits into from

Conversation

lukekarrys
Copy link
Collaborator

  • add test

Copy link

changeset-bot bot commented Mar 31, 2024

🦋 Changeset detected

Latest commit: 8c4833d

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

Copy link

vercel bot commented Mar 31, 2024

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

@erickythierry
Copy link

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?

@lukekarrys
Copy link
Collaborator Author

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);
});

@erickythierry
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants