I'm interested in capturing the Internet Protocol (IP) address of my users at their initial submit to my website. I was under the impression that a SvelteKit submit would be similar to other node.js server solution.
I've been all over this posting, and I'm just not seeing anything remotely like req.headers['x-forwarded-for']
or req.socket.remoteAddress
in my request submit to API server in SvelteKit.
Here's what I do see in the request (via a console log in the API submit):
arg1: body: (... data ... ) Headers: accept:'*/*' accept-encoding:'gzip, deflate' accept-language:'en-US,en;q=0.9' connection:'keep-alive' content-length:'141' content-type:'text/plain;charset=UTF-8' cookie:'userid=c03efd10-3085-46cb-bacd-9eaeb605426e' host:'192.168.1.22:3000' origin:'http://192.168.1.22:3000' referer:'http://192.168.1.22:3000/learn' user-agent:'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36' locals: userid: '....' method: 'POST' params: {} path: '/api/user_form' query: ... rawBody: ...
Definitely no socket
, no header for ['x-forwarded-for']
Note, I'm working this on local network. Host on one machine, client on another machine in the same network. In fact, host = 192.168.1.22:3000, client = 192.168.1.4
Note2, I'm running the program via svelte-kit dev --host 0.0.0.0
What am I not seeing? Is there a way to obtain a client user's IP address from a websubmit using Sveltekit?