@@ -65,11 +65,7 @@ import {
6565 OpenRouterError ,
6666} from '@/llm-api/openrouter'
6767import { checkSessionAdmissible } from '@/server/free-session/public-api'
68- import {
69- extractClientIp ,
70- getFreeModeCountryAccess ,
71- getFreeModeCountryCodeForClient ,
72- } from '@/server/free-mode-country'
68+ import { getFreeModeCountryAccess } from '@/server/free-mode-country'
7369
7470import type { SessionGateResult } from '@/server/free-session/public-api'
7571import { extractApiKeyFromHeader } from '@/util/auth'
@@ -261,15 +257,14 @@ export async function postChatCompletions(params: {
261257 // For free mode requests, require a resolved allowlisted country.
262258 if ( isFreeModeRequest ) {
263259 const countryAccess = getFreeModeCountryAccess ( req )
264- const clientIp = extractClientIp ( req )
265260
266261 logger . info (
267262 {
268263 cfHeader : countryAccess . cfCountry ,
269264 geoipResult : countryAccess . geoipCountry ,
270265 resolvedCountry : countryAccess . countryCode ,
271266 countryBlockReason : countryAccess . blockReason ,
272- clientIp : clientIp ? '[redacted]' : undefined ,
267+ clientIp : countryAccess . hasClientIp ? '[redacted]' : undefined ,
273268 } ,
274269 'Free mode country detection' ,
275270 )
@@ -282,7 +277,7 @@ export async function postChatCompletions(params: {
282277 error : 'free_mode_not_available_in_country' ,
283278 countryCode : countryAccess . countryCode ,
284279 countryBlockReason : countryAccess . blockReason ,
285- clientIp : clientIp ? '[redacted]' : undefined ,
280+ clientIp : countryAccess . hasClientIp ? '[redacted]' : undefined ,
286281 } ,
287282 logger,
288283 } )
@@ -291,7 +286,7 @@ export async function postChatCompletions(params: {
291286 {
292287 error : 'free_mode_unavailable' ,
293288 message : 'Free mode is not available in your country.' ,
294- countryCode : getFreeModeCountryCodeForClient ( countryAccess ) ,
289+ countryCode : countryAccess . countryCode ?? 'UNKNOWN' ,
295290 } ,
296291 { status : 403 } ,
297292 )
0 commit comments