From bb9b73557bd98d8a3a1f7ab63451c86b804fa6ec Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Tue, 6 Jan 2026 17:33:19 +0800 Subject: [PATCH] fix: use ipinfo lite API with token for IP country detection (#12312) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: use ipinfo lite API with token for IP country detection Switch from ipinfo.io/json to api.ipinfo.io/lite/me endpoint with authentication token to improve reliability and avoid rate limiting. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 * fix: use country_code field from ipinfo lite API response The lite API returns country_code instead of country field. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --------- Co-authored-by: Claude Sonnet 4.5 --- src/main/utils/ipService.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/utils/ipService.ts b/src/main/utils/ipService.ts index 3180f9457c..708af4c40e 100644 --- a/src/main/utils/ipService.ts +++ b/src/main/utils/ipService.ts @@ -13,18 +13,13 @@ export async function getIpCountry(): Promise { const controller = new AbortController() const timeoutId = setTimeout(() => controller.abort(), 5000) - const ipinfo = await net.fetch('https://ipinfo.io/json', { - signal: controller.signal, - headers: { - 'User-Agent': - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36', - 'Accept-Language': 'en-US,en;q=0.9' - } + const ipinfo = await net.fetch(`https://api.ipinfo.io/lite/me?token=2a42580355dae4`, { + signal: controller.signal }) clearTimeout(timeoutId) const data = await ipinfo.json() - const country = data.country || 'CN' + const country = data.country_code || 'CN' logger.info(`Detected user IP address country: ${country}`) return country } catch (error) {