fix: restore @ts-expect-error for request.ip in getClientIp
The property was removed from NextRequest types in Next.js 15+ but is still populated by hosting platforms (Vercel, Netlify, etc.). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,8 @@ import { getConfig } from './config';
|
|||||||
|
|
||||||
export function getClientIp(request: NextRequest): string {
|
export function getClientIp(request: NextRequest): string {
|
||||||
const config = getConfig();
|
const config = getConfig();
|
||||||
const directIp = request.ip; // Populated by Next.js if on Vercel/Netlify
|
// @ts-expect-error - Next.js 15+ removed request.ip from types but hosting platforms still populate it
|
||||||
|
const directIp = request.ip as string | undefined;
|
||||||
|
|
||||||
const xForwardedFor = request.headers.get('x-forwarded-for');
|
const xForwardedFor = request.headers.get('x-forwarded-for');
|
||||||
const xRealIp = request.headers.get('x-real-ip');
|
const xRealIp = request.headers.get('x-real-ip');
|
||||||
|
|||||||
Reference in New Issue
Block a user