fix(api): 🐛 get correct client ip even through server proxy

This commit is contained in:
Julien Oculi 2024-06-22 16:02:12 +02:00
parent 7568cb43a6
commit ad34e6a3e4

View file

@ -51,7 +51,9 @@ export const handler: SessionHandlers = {
// send mail to user
try {
if (user) {
const ip = ctx.remoteAddr.hostname
// Get user ip through proxy else from tcp connection
const ip = request.headers.get('X-FORWARDED-FOR') ??
ctx.remoteAddr.hostname
const device = request.headers.get('Sec-Ch-Ua-Platform') ?? undefined
await sendMagicLink(user, { device, ip, endpoint })