doge 18 hours ago
parent
commit
1b91cf6a4b
1 changed files with 2 additions and 2 deletions
  1. 2 2
      app/Services/Agent/AgentContextService.php

+ 2 - 2
app/Services/Agent/AgentContextService.php

@@ -30,8 +30,8 @@ class AgentContextService
         // 优先读取 CDN/网关在边缘完成的 IP 归属地;没有时保留空值,避免登录依赖外部接口。
         return [
             'country' => mb_substr((string) ($request->header('CF-IPCountry') ?: $request->header('X-IP-Country', '')), 0, 128),
-            'region' => mb_substr((string) $request->header('X-IP-Region', ''), 0, 128),
-            'city' => mb_substr((string) $request->header('X-IP-City', ''), 0, 128),
+            'region' => mb_substr((string) ($request->header('CF-Region') ?: $request->header('X-IP-Region', '')), 0, 128),
+            'city' => mb_substr((string) ($request->header('CF-IPCity') ?: $request->header('X-IP-City', '')), 0, 128),
         ];
     }
 }