Skip to content

Conversation

@mission-sun
Copy link

After the framework recently replaced the request library from axios with fetch, it was found that the native fetch only supports HTTPS proxies and cannot be compatible with existing SOCKS proxy scenarios. To address this issue, the current

adjustment plan is as follows:

  1. Use node-fetch instead of the native fetch to support both HTTPS and SOCKS proxies.
  2. Redefine the FetchRequestInit type to avoid type conflicts.
  3. Keep the dispatcher parameter to ensure compatibility with older versions.

@whiskeysockets-bot
Copy link
Contributor

Thanks for opening this pull request and contributing to the project!

The next step is for the maintainers to review your changes. If everything looks good, it will be approved and merged into the main branch.

In the meantime, anyone in the community is encouraged to test this pull request and provide feedback.

✅ How to confirm it works

If you’ve tested this PR, please comment below with:

Tested and working ✅

This helps us speed up the review and merge process.

📦 To test this PR locally:

# NPM
npm install @whiskeysockets/baileys@mission-sun/Baileys#master

# Yarn (v2+)
yarn add @whiskeysockets/baileys@mission-sun/Baileys#master

# PNPM
pnpm add @whiskeysockets/baileys@mission-sun/Baileys#master

If you encounter any issues or have feedback, feel free to comment as well.

Salientekill pushed a commit to Salientekill/Baileys that referenced this pull request Nov 11, 2025
…proxies

- Add proxy support for HTTP/HTTPS and SOCKS4/SOCKS5
- Update types for proxy configuration
- Add proxy handling in multiple utility files
- Update dependencies for proxy support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copy link

@sahilashraff sahilashraff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export const getHttpStream = async (url, options = {}) => {
const response = await fetch(url.toString(), {
agent: options.dispatcher,
method: 'GET',
headers: options.headers,
});

if (!response.ok) {
throw new Boom(Failed to fetch stream from ${url}, {
statusCode: response.status,
data: { url },
});
}

const body = response.body;

// ✅ If it's already a Node stream (Gunzip, fs.ReadStream, etc.), return as-is
if (body && typeof body.pipe === 'function') {
return body;
}

// ✅ Otherwise (older Node versions) convert Web ReadableStream to Node Readable
if (typeof Readable.fromWeb === 'function' && body instanceof ReadableStream) {
return Readable.fromWeb(body);
}

// ✅ Fallback: just return whatever it is
return body;
};

the response is already Gunzip, don’t try to re-unzip or re-convert it.

@purpshell
Copy link
Member

This breaks web compatibility. @jlucaso1 any thoughts

@fwidjaja94
Copy link
Contributor

There are libraries available for SOCKS proxy support with undici (the Node.js built-in fetch).

Here's one you can use:
https://www.npmjs.com/package/fetch-socks

@github-actions
Copy link
Contributor

github-actions bot commented Dec 6, 2025

This PR is stale because it has been open for 14 days with no activity. Remove the stale label or comment or this will be closed in 14 days

@github-actions github-actions bot added the Stale label Dec 6, 2025
@vinikjkkj
Copy link
Collaborator

is it a duplicate of #1877 ?

@github-actions github-actions bot removed the Stale label Dec 13, 2025
@github-actions
Copy link
Contributor

This PR is stale because it has been open for 14 days with no activity. Remove the stale label or comment or this will be closed in 14 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants