From 1b6786a10c45b48bc495035ef2155e78ca20e9fd Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Wed, 13 Mar 2024 13:40:24 -0700 Subject: [PATCH] client_ip: fallback to REMOTE_ADDR --- reflex/app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reflex/app.py b/reflex/app.py index 4aa302a508..c15b12dc1f 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -1146,7 +1146,10 @@ async def on_event(self, sid, data): } # Get the client IP - client_ip = environ["asgi.scope"]["client"][0] + try: + client_ip = environ["asgi.scope"]["client"][0] + except (KeyError, IndexError): + client_ip = environ.get("REMOTE_ADDR", "0.0.0.0") # Process the events. async for update in process(self.app, event, sid, headers, client_ip):