Skip to content

request.remote_addr is broken only inside socketio #1826

Answered by miguelgrinberg
4n1qz5skwv asked this question in Q&A
Discussion options

You must be logged in to vote

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
Loading

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
Loading

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@4n1qz5skwv
Comment options

@miguelgrinberg
Comment options

Answer selected by 4n1qz5skwv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1825 on June 08, 2022 13:32.