Skip to content

fix: resolve Bing 301 redirect and Baidu TLS handshake failure#94

Open
sublatesublate-design wants to merge 1 commit into
Aas-ee:mainfrom
sublatesublate-design:fix/bing-301-baidu-tls
Open

fix: resolve Bing 301 redirect and Baidu TLS handshake failure#94
sublatesublate-design wants to merge 1 commit into
Aas-ee:mainfrom
sublatesublate-design:fix/bing-301-baidu-tls

Conversation

@sublatesublate-design
Copy link
Copy Markdown

Problem

Bing and Baidu search engines are broken:

  1. Bing: cn.bing.com/search now returns a 301 redirect to www.bing.com. Since trustedStaticHost=true enforces maxRedirects=0, the redirect is thrown as an error instead of being followed.

  2. Baidu: Node.js v24 defaults to TLS 1.3, but Baidu's CDN does not support TLS 1.3 (returns a TLS alert). The TLS handshake hangs or fails with ECONNRESET. TLS 1.2 works fine.

Changes

Bing fix (src/engines/bing/bing.ts, src/engines/bing/parser.ts)

  • Change BING_BASE_URL from https://cn.bing.com/search to https://www.bing.com/search
  • Update the hardcoded cn.bing.com in parser.ts for relative URL reconstruction to match
  • The Playwright fallback path already uses www.bing.com (BING_HOME_URL), and isBingUrl() accepts *.bing.com

Baidu fix (src/utils/httpRequest.ts)

  • Add a new cached getTrustedStaticHttpsAgent() that creates an https.Agent with maxVersion: 'TLSv1.2'
  • In the trustedStaticHost branch of buildAxiosRequestOptions, always assign an httpsAgent (previously only assigned when allowInsecureTls=true)
  • This limits TLS negotiation to 1.2 max for trusted static host requests, fixing the Baidu CDN incompatibility without affecting other engines (TLS 1.2 is universally supported)

Testing

  • Baidu: confirmed returning 3 results after fix (previously failed with TLS handshake error)
  • Bing: 301 error eliminated; www.bing.com now serves JS-rendered content (no SSR results in HTTP mode, but this is a pre-existing Bing change — Playwright fallback handles it)
  • DuckDuckGo and Sogou: unaffected, continue to work

🤖 Generated with Claude Code

- Change BING_BASE_URL from cn.bing.com to www.bing.com to fix 301
  redirect (cn.bing.com now permanently redirects to www.bing.com)
- Update parser.ts relative URL base to match
- Add TLS 1.2 maxVersion agent for trustedStaticHost requests,
  fixing Baidu CDN TLS 1.3 incompatibility on Node.js v24+

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Aas-ee
Copy link
Copy Markdown
Owner

Aas-ee commented May 29, 2026

lgtm

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.

2 participants