-
In FastAPI I want to get the client's IP address to implement rate limiting/anti-spam protection. Using @app.get('/api/test')
async def test(request: Request):
return {'ip': request.client.host, 'headers': request.headers} Result: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
unfortunately this is a limitation of amazon global accelerator, which we're using for geo routing. GA doesn't forward the client's IP. we're working out a plan to replace it, nothing concrete yet. |
Beta Was this translation helpful? Give feedback.
-
Edit: A follow-up, I resolved my use case using fly.io and deploying a Docker container there, their free tier has shown to be enough so far with both IPv4/6 available Hello, just adding my comment here so I get a notification when there is an update 🙂 Some context regarding why I'm waiting for this implementation and why I need it: I've currently implemented an API endpoint with Express.js for the Nextcloudpi project using Deta, it checks if the ports 80 & 443 are open and properly configured with port-forwarding and sends a JSON response with data about which ones are open. I decided to implement a solution for this myself using Deta instead of using external sites as we currently do right now, since they aren't always very happy about having repeated requests on their free services. For security reason, or mainly just to reduce the potential for abuse, it would be great to be able to fetch the client's IP from the header instead of using it within a POST payload, that way it would only check the ports of the client calling the endpoint which in this case would be the device deploying a Nextcloudpi instance. |
Beta Was this translation helpful? Give feedback.
-
My solution is following.
Notice: You must set SSL/TLS encryption mode to |
Beta Was this translation helpful? Give feedback.
unfortunately this is a limitation of amazon global accelerator, which we're using for geo routing. GA doesn't forward the client's IP. we're working out a plan to replace it, nothing concrete yet.