D
Dokploy7mo ago
Leech

cloudflare real ips NextJS App

I have a domain in cloudflare that is directed to the server and I need to get the user’s IP in the NextJS application, but because cloudflare the ip is not real, I tried to use traefik plugins, but due to the old version they are not available. Here's the NextJS code where I'm trying to get the user's IP: export async function GET(req: Request, { params }: { params: { api_key: string } }) { const ip = req.headers.get('X-Forwarded-For'); console.log(ip); } this code return cloudflare's ip 162.158.74.35
1 Reply
Leech
LeechOP7mo ago
use CF-Connecting-IP and it work

Did you find this page helpful?