diff options
| author | Yuval Adam <_@yuv.al> | 2018-10-08 13:43:21 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2018-10-08 13:43:21 +0300 |
| commit | 8fa363de6fff88f6d80a4bd6dbc2fc141e5a6ed8 (patch) | |
| tree | 94ad6679075738c2eab27c2130b737447b3e1051 /app.py | |
| parent | b4600e01f4bd73981b16da5ce9788f8f32b3c5fa (diff) | |
Support multiple IPs in header
Diffstat (limited to 'app.py')
| -rw-r--r-- | app.py | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -5,7 +5,10 @@ app = Flask(__name__) def get_ip(request): if 'PROD' in environ: - return request.headers.get('X-Forwarded-For') + # Heroku routing layers masks the original IP, fetch it from the custom header + # And make sure we just take the first IP in case other proxies were in the way + ips = request.headers.get('X-Forwarded-For') + return ips.split(',')[0] else: return request.remote_addr |
