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?
8 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
#ask-ai referred me to this post https://discord.com/channels/1019350475847499849/1281699105101451284 which answered my question.
What's your goal with this? Currently the incoming IP address is not exposed even in an httpAction.
It's for simple analytics of users' geographical distribution.
If Convex were to expose as an extra header or ctx.meta.geo property would you want the geographical location directly, or still the IP address?
For my use case,
ctx.meta.geo
would be great.For my use case, I’m looking to implement an IP-based rate limiter in Convex. This would require reading the client’s IP address within an action. Is there currently any way to access the IP address server-side in Convex without having to rely on the client to send it?
@ballingt I would definitely use this too. To rate limit on IP address I have to use a http endpoint. I think for me I'd probably want the raw details from the http request (presumably) that happens when initating the web socket