diff --git a/src/app/api/v1/payment-links/route.ts b/src/app/api/v1/payment-links/route.ts index 679f324..03280f8 100644 --- a/src/app/api/v1/payment-links/route.ts +++ b/src/app/api/v1/payment-links/route.ts @@ -140,14 +140,14 @@ export async function POST(req: NextRequest) { } // 6. Log API call (optional/async) - const clientIp = req.headers.get('x-forwarded-for') || 'unknown' + const clientIp = (req.headers.get('x-forwarded-for') || 'unknown').split(',')[0].trim() supabase.from('api_logs').insert({ merchant_id: merchant.id, endpoint: '/api/v1/payment-links', method: 'POST', status_code: 201, request_body: body, - ip_address: clientIp.split(',')[0], + ip_address: clientIp, // eslint-disable-next-line @typescript-eslint/no-explicit-any }).then(({ error }: any) => { if (error) console.error('Failed to log API call', error) diff --git a/src/lib/api/verify-api-key.ts b/src/lib/api/verify-api-key.ts index 9b858a8..fc504ef 100644 --- a/src/lib/api/verify-api-key.ts +++ b/src/lib/api/verify-api-key.ts @@ -57,7 +57,7 @@ export async function verifyApiKey(req: NextRequest) { endpoint: req.nextUrl.pathname, method: req.method, status_code: 200, // Assumed success if we get here - ip_address: req.headers.get('x-forwarded-for') || 'unknown', + ip_address: (req.headers.get('x-forwarded-for') || 'unknown').split(',')[0].trim(), user_agent: req.headers.get('user-agent') || 'unknown' // eslint-disable-next-line @typescript-eslint/no-explicit-any }).then(({ error }: any) => {