diff --git a/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc b/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc index 06d0baea..46eeb9e4 100644 Binary files a/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc and b/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc differ diff --git a/osinaweb/osichat/consumers.py b/osinaweb/osichat/consumers.py index a8c18020..f69fcb94 100644 --- a/osinaweb/osichat/consumers.py +++ b/osinaweb/osichat/consumers.py @@ -10,7 +10,13 @@ import requests class OsitcomVisitor(WebsocketConsumer): def connect(self): self.accept() - self.visitor_ip = self.scope.get('client', [''])[0] + ip_address = self.scope.get('headers', {}).get('x-forwarded-for', None) + if ip_address: + self.visitor_ip = ip_address.split(',')[0].strip() + else: + self.visitor_ip = self.scope.get('client', [None])[0] + + if self.visitor_ip: response = requests.get(f'http://ipinfo.io/{self.visitor_ip}/json') data = response.json()