refactor: IP归属地改为apihz.cn id+key配置,后端测试修复验证条件
This commit is contained in:
@@ -10,9 +10,10 @@ export async function lookupIpLocation(ip: string): Promise<string | null> {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const apiUrlTemplate = getSystemConfig('ip_geo_api_url');
|
||||
if (!apiUrlTemplate) return null;
|
||||
const url = apiUrlTemplate.replace('{ip}', encodeURIComponent(ip));
|
||||
const apiId = getSystemConfig('ip_geo_api_id');
|
||||
const apiKey = getSystemConfig('ip_geo_api_key');
|
||||
if (!apiId || !apiKey) return null;
|
||||
const url = `https://cn.apihz.cn/api/ip/chaapi.php?id=${encodeURIComponent(apiId)}&key=${encodeURIComponent(apiKey)}&ip=${encodeURIComponent(ip)}&td=0`;
|
||||
|
||||
const res = await fetch(url, { signal: AbortSignal.timeout(5000) });
|
||||
if (!res.ok) return null;
|
||||
|
||||
Reference in New Issue
Block a user