Skip to content

Commit 92032a8

Browse files
committed
fix(twitter): update proxy agent implementation to use new Client and HttpCookieAgentCookie
1 parent d03f569 commit 92032a8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/routes/twitter/api/web-api/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { baseUrl, gqlFeatures, bearerToken, gqlMap, thirdPartySupportedAPI } fro
33
import { config } from '@/config';
44
import queryString from 'query-string';
55
import { Cookie, CookieJar } from 'tough-cookie';
6-
import { CookieAgent, CookieClient } from 'http-cookie-agent/undici';
7-
import { ProxyAgent } from 'undici';
6+
import { CookieAgent, cookie as HttpCookieAgentCookie } from 'http-cookie-agent/undici';
7+
import { ProxyAgent, Client } from 'undici';
88
import cache from '@/utils/cache';
99
import logger from '@/utils/logger';
1010
import ofetch from '@/utils/ofetch';
@@ -23,7 +23,7 @@ const token2Cookie = async (token) => {
2323
try {
2424
const agent = proxy.proxyUri
2525
? new ProxyAgent({
26-
factory: (origin, opts) => new CookieClient(origin as string, { ...opts, cookies: { jar } }),
26+
factory: (origin, opts) => new Client(origin as string, opts).compose(HttpCookieAgentCookie({ jar })),
2727
uri: proxy.proxyUri,
2828
})
2929
: new CookieAgent({ cookies: { jar } });
@@ -110,7 +110,7 @@ export const twitterGot = async (
110110
const jar = CookieJar.deserializeSync(cookie as any);
111111
const agent = proxy.proxyUri
112112
? new ProxyAgent({
113-
factory: (origin, opts) => new CookieClient(origin as string, { ...opts, cookies: { jar } }),
113+
factory: (origin, opts) => new Client(origin as string, opts).compose(HttpCookieAgentCookie({ jar })),
114114
uri: proxy.proxyUri,
115115
})
116116
: new CookieAgent({ cookies: { jar } });

0 commit comments

Comments
 (0)