Skip to content

fix: use configured base URL for QR login (all SDKs) - #83

Open
jeffkit wants to merge 1 commit into
corespeed-io:mainfrom
jeffkit:fix/qr-login-respect-configured-base-url
Open

fix: use configured base URL for QR login (all SDKs)#83
jeffkit wants to merge 1 commit into
corespeed-io:mainfrom
jeffkit:fix/qr-login-respect-configured-base-url

Conversation

@jeffkit

@jeffkit jeffkit commented Jun 6, 2026

Copy link
Copy Markdown

Summary

QR login (get_bot_qrcode / get_qrcode_status) previously always called https://ilinkai.weixin.qq.com, ignoring BotOptions.baseUrl / Options.BaseURL / options.baseUrl / base_url.

Message APIs already respected the configured base URL. This change aligns the login path so clients can pair through local proxy hubs (e.g. iLink Hub) by only setting WEIXIN_BASE_URL.

Changes

SDK File
Rust rust/src/bot.rs
Go golang/internal/auth/login.go
Node.js nodejs/src/auth/authenticator.ts
Python python/wechatbot/auth.py

IDC redirect (scaned_but_redirect) behavior is unchanged — polling may still switch to redirect_host when returned by Tencent.

Test plan

  • cargo test in rust/ (46 tests pass)
  • Point baseUrl at a mock hub; verify get_bot_qrcode hits the mock, not Tencent
  • Default behavior unchanged when baseUrl is omitted (still ilinkai.weixin.qq.com)

Made with Cursor

QR code fetch and status polling previously always hit
ilinkai.weixin.qq.com even when BotOptions.baseUrl pointed at a
local proxy hub (e.g. iLink Hub). Message APIs already respected
baseUrl; this aligns the login path for hub pairing and custom
gateways.

Affected: Rust, Go, Node.js, Python SDKs.
Co-authored-by: Cursor <cursoragent@cursor.com>
@spinsirr

Copy link
Copy Markdown
Collaborator

Conclusion: Approve

Overall assessment: A clean, well-scoped bug fix. The QR-login path (get_bot_qrcode / poll) previously hardcoded https://ilinkai.weixin.qq.com and ignored the configured base URL, which blocked pairing through local proxy hubs. The fix removes the duplicate FIXED_QR_BASE_URL/fixedQRBaseURL constant from each SDK and routes the QR request and initial poll through the already-resolved configured base_url. The change is applied consistently across all four SDKs, config precedence is correct, and the IDC redirect behavior is preserved.

Review scope: Reviewed the full diff plus the surrounding base-URL resolution in each SDK's login module to confirm the configured value is sourced correctly and no hardcoded fallback remains: golang/internal/auth/login.go, nodejs/src/auth/authenticator.ts, python/wechatbot/auth.py, rust/src/bot.rs. Cross-checked the default-URL constants in golang/internal/protocol/api.go:21, nodejs/src/protocol/types.ts:10, python/wechatbot/protocol.py:19, and rust/src/bot.rs:67.

What looks good:

  • Consistent across all four SDKs. Each removes the local fixed constant and passes the resolved configured base URL to both getQrCode and the initial poll URL.
  • Config precedence is correct in every SDK. The value flows from the configured option down to the protocol-level DEFAULT_BASE_URL fallback, so omitting the option preserves the original ilinkai.weixin.qq.com default. Verified: Go login.go:86-88 (opts.BaseURLprotocol.DefaultBaseURL), Node authenticator.ts:44 (options.baseUrl ?? DEFAULT_BASE_URL), Python auth.py:62 (base_url: str = DEFAULT_BASE_URL), Rust bot.rs:66-68 (opts.base_url.unwrap_or_else(... DEFAULT_BASE_URL)).
  • No hardcoded QR URL remains anywhere in the login flow. The only literal ilinkai.weixin.qq.com strings left are the single per-SDK protocol default constants, which is the right place for them — duplication is eliminated.
  • IDC redirect (scaned_but_redirect) is correctly untouched: polling still switches to https://{redirect_host} when Tencent returns one (Go login.go:168, Node authenticator.ts, Python auth.py:135, Rust bot.rs:150), and the persisted credential base URL still prefers the server-returned baseurl over the configured one (Go login.go:148-150, Rust bot.rs:136, etc.).

Must fix: None.

Should improve: None.

Optional: Consider a small regression test that asserts get_qr_code is invoked with the configured base URL when one is set (the unchecked items in the PR test plan). Not blocking, but it would lock in the exact behavior this fix restores.

Questions: None.

Testing / Risk: Low risk. Pure substitution of an already-resolved configured value for a literal that, by default, equals the same string — so default behavior is unchanged and the proxy-hub case is now supported. No CI checks are configured on this repo/branch (gh pr checks reports none), so verification rests on the author's cargo test (46 pass) and manual review. The two unchecked manual test-plan items (mock-hub hit + default-unchanged) are worth confirming before relying on this in production.

Next step: Approve and merge. Optionally run the two manual test-plan checks against a mock hub first.

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