MegaHydronicsM
Convex Community14mo ago
9 replies
MegaHydronics

Accessing client IP address in a query/mutation

Good day. Any help would be appreciated, as I am fairly new to Convex.
Is there a way to expose HTTP headers, such as for obtaining the IP address in the example below? Or is an httpAction required for this use case?
const registerClient = mutation({
  args: { userAgent: v.string() },
  handler: async (ctx, { userAgent }) => {
    // get ip address from 'x-forwarded-for' header
    await ctx.db.insert('client', { userAgent, ip })
  }
})
Was this page helpful?