RSSHub/lib/routes/twitter/api/web-api
Guorui Yu d8eaee5889
fix(route/twitter): dynamically resolve GraphQL query IDs and fix production CookieAgent (#21544)
* fix(route/twitter): dynamically resolve GraphQL query IDs from Twitter JS bundles

Twitter rotates GraphQL query IDs every 2-4 weeks, causing 404 errors.
Instead of relying solely on hardcoded IDs, fetch and cache the latest
query IDs from Twitter's client-web main.js bundle at runtime.

- Add gql-id-resolver module to extract queryId/operationName pairs
- Cache resolved IDs using CACHE_CONTENT_EXPIRE (Redis supported)
- Fall back to hardcoded IDs if dynamic resolution fails
- Update init() to trigger resolution before first API call

Signed-off-by: yuguorui <yuguorui@pku.edu.cn>

* fix(route/twitter): use undici.fetch directly to preserve CookieAgent dispatcher

Both ofetch and the global wrappedFetch (request-rewriter) drop the
dispatcher option when constructing a new Request object, which prevents
the CookieAgent from attaching cookies in production builds. Use
undici.fetch directly for Twitter API requests to preserve the dispatcher.

Signed-off-by: yuguorui <yuguorui@pku.edu.cn>

---------

Signed-off-by: yuguorui <yuguorui@pku.edu.cn>
2026-04-06 22:46:29 +08:00
..
api.ts fix(route/twitter): dynamically resolve GraphQL query IDs and fix production CookieAgent (#21544) 2026-04-06 22:46:29 +08:00
constants.ts fix(route/twitter): dynamically resolve GraphQL query IDs and fix production CookieAgent (#21544) 2026-04-06 22:46:29 +08:00
gql-id-resolver.ts fix(route/twitter): dynamically resolve GraphQL query IDs and fix production CookieAgent (#21544) 2026-04-06 22:46:29 +08:00
login.ts chore(deps): bump otplib from 12.0.1 to 13.0.2 (#20855) 2026-01-12 23:49:56 +08:00
utils.ts fix(route/twitter): dynamically resolve GraphQL query IDs and fix production CookieAgent (#21544) 2026-04-06 22:46:29 +08:00