Skip to content

fix(docs): add fallback chain for geo IP detection - #184

Merged
cc-hearts merged 1 commit into
mainfrom
fix/geo-ip-fallback-chain
Aug 13, 2026
Merged

fix(docs): add fallback chain for geo IP detection#184
cc-hearts merged 1 commit into
mainfrom
fix/geo-ip-fallback-chain

Conversation

@cc-hearts

Copy link
Copy Markdown
Member

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

None.

💡 Background and Solution

The docs site asks mainland-China visitors whether they want to be redirected to x.antdv-next.cn. The geo lookup relied on a single endpoint, https://v4_dx.boce.com:44433/ipaddr, which is frequently unreachable (non-standard port, unstable availability). Whenever it fails, getChinaMainlandRedirectDecision() returns skip and the redirect prompt never appears for the users it was built for.

This PR replaces the single endpoint with an ordered fallback chain. Each API is tried in turn; the first one that responds successfully decides the outcome, and probing stops there — a successful non-CN result does not fall through to the next provider. If every request fails, the behaviour is unchanged: return skip silently so the page is never blocked.

The chain, in order:

Endpoint Response Notes
https://myip.ipip.net plain text Domestic service, fast, CORS-friendly. Hong Kong / Macau / Taiwan are excluded, since ipip.net labels them as 中国香港 / 中国澳门 / 中国台湾.
https://api.ip.sb/geoip JSON country_code HK / TW / MO are distinct from CN, so no extra filtering is needed.
https://v4_dx.boce.com:44433/ipaddr JSON data.from The original endpoint, kept as a last-resort fallback (same API the antdv-next main site uses).

Parsing is now per-API via a parse(text: string) => boolean hook, so each provider owns its own response format, and the timeout was raised from 1200ms to 1500ms per attempt to reduce false negatives on slow connections.

No user-facing API changed — this only affects the docs site's internal geo detection.

📝 Change Log

Language Changelog
🇺🇸 English Fix the mainland-China redirect prompt on the docs site not showing when the geo IP endpoint is unreachable, by adding a fallback chain of geo IP providers.
🇨🇳 Chinese 修复文档站点 IP 地理定位接口不可用时,国内站点跳转提示不显示的问题,改为按顺序尝试多个地理定位接口。

The boce.com geo IP endpoint is frequently unreachable, which silently
disables the CN-site redirect prompt. Try myip.ipip.net and api.ip.sb
first, falling back to boce.com only as a last resort.
@cc-hearts
cc-hearts merged commit 8f41e5e into main Aug 13, 2026
7 checks passed
@cc-hearts
cc-hearts deleted the fix/geo-ip-fallback-chain branch August 13, 2026 02:36
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.

1 participant