#Getting request information

3 messages · Page 1 of 1 (latest)

cerulean surge
#

Is it possible to get request information from within a query for example. The client calls the query, is it possible to get the client's ip address and other request information?

fleet knollBOT
#

Hi @cerulean surge. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Currently, it is not possible to access the client's IP address or other request information from within a Convex query. The Convex platform does not expose HTTP headers or request metadata (such as IP address or user agent) in queries, mutations, or even actions at this time. This limitation is due to the way Convex handles caching and determinism in queries and mutations—exposing request-specific data would break the cache integrity.

There have been community requests for this feature, and the Convex team has discussed possible future approaches (such as exposing this information via something like ctx.meta.ip), but as of now, this is not available. If you need to access request information like the IP address, you would need to handle it outside of Convex, for example, by using a traditional serverless function (e.g., on Vercel or Netlify) and then passing the information to Convex if needed. Alternatively, you could use an httpAction, but even there, the IP address is not currently exposed by Convex itself How to get request.ip inside a convex server function? (Discord) Accessing client IP address in a query/mutation (Discord).

In summary:
No, you cannot currently access the client's IP address or other request information from within a Convex query.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: