#[SOLVED] how to get client ip in functions ?

3 messages · Page 1 of 1 (latest)

fresh compass
#

i use "req.headers['x-real-ip'] || req.connection.remoteAddress", but it doesn't work.
Because I allow users to execute functions that, upon execution, write data to the database with parameters, and also write the IP address to the database. This data is for tracking user behavior. My users do not need to log in and are all guest visitors, not logged into the system.

errant marten
#

Hey there 👋 HTTP interface of functions is currently limited, as it is defined by REST API. In next iteration of functions, which I am actively working on, you will be allowed to get request headers, body, method and URL.

For now whst you can do is to create a simple proxy that executes Appwrite Function on each request, passing everything about the request as a payload. Example of this, and 1click solution for Railway can be found here: https://github.com/Meldiron/railway-webhook-proxy

GitHub

Webhook proxy to trigger Appwrite Function. Hosted for free on Railway. - GitHub - Meldiron/railway-webhook-proxy: Webhook proxy to trigger Appwrite Function. Hosted for free on Railway.