Request "ip" property is undefined, even deployed on Vercel

Even with the project deployed to Vercel, the “ip” property on the NextRequest request object in a Route Handler is undefined. I have a deployed website to prove this.

Website route: https://vercel-req-ip-test.vercel.app/api/ip

This page returns your ip by the request.ip and from the headers.

Source code: GitHub - Nic13Gamer/vercel-req-ip-test

Hi, @nic13gamer!

I found this old GitHub Discussions thread with a solution, does this work for you?

Hey!

The headers do give the IP information, however using request.ip is more secure right?

The docs say request.ip should be provided on deployments on Vercel, but this is not happening to me.

Thank you!