request.remote_addr is broken only inside socketio #1826
-
App Info:App is hosted on heroku and domain is in cloudflare. So Proxy Fix:
. Example Code inside A Route:
Output:
Here, Example Code inside an Event Function:
Output:
Here, My IP Address from "whatismyipaddress.com"
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Edit: Updated with recent data. |
Beta Was this translation helpful? Give feedback.
-
The problem is that you are applying the ProxyFix middleware to the Flask application too early, before SocketIO has a chance to reconfigure the middlewares to include itself. So you end up with something like this: graph LR
SocketIO-Middleware --> ProxyFix
ProxyFix --> Flask-App
SocketIO-Middleware --> SocketIO-App
which leaves the SocketIO side without coverage. If you initialize Socket.IO before adding ProxyFix you would have a better looking structure: graph LR
ProxyFix --> SocketIO-Middleware
SocketIO-Middleware --> Flask-App
SocketIO-Middleware --> SocketIO-App
|
Beta Was this translation helpful? Give feedback.
The problem is that you are applying the ProxyFix middleware to the Flask application too early, before SocketIO has a chance to reconfigure the middlewares to include itself. So you end up with something like this:
which leaves the SocketIO side without coverage. If you initialize Socket.IO before adding ProxyFix you would have a better looking structure: