NextJS 13.4 - how to get the ip address using server functions.

Hey! i have two questions to ask.. first, i have a server function passed to a button and getting something for backend but sadly i don't know how to get the ip address.. when i use the NextRequest the ip property returns undefined and the geo returns empty json object.. so how can i get the ip address? second and last, there's a header X-Forwarded-For and can be hacked/abused from clients by passing a custom header.. so i don't need to go deep to protect this (no clue if vercel or others protected this) so how can i protect this?
3 Replies
wolfulus
wolfulus11mo ago
app or pages router?
itsMU1X
itsMU1X11mo ago
app router
dysbulic 🐙
dysbulic 🐙11mo ago
http.dev
Access-Control-Allow-Headers
What is 'Access-Control-Allow-Headers'? Learn how to utilize this HTTP header, with free examples and code snippets.