I have a Flask app running on port 5000. My server admin has configured nginx to forward this to port 5001 (sorry if I have the wrong terminology: the Flask app is running on port 5000, but the app is publicly accessible at http://the_url:5001).
All routes accessed directly in the browser work, but any redirect using url_for() seem to result in the port being missed from the URL — i.e. redirect(url_for('index')) redirects to http://the_url/ rather than http://the_url:5001/ (where the @app.route("/") triggers the function index()).
How do I make sure Flask adds the correct port when redirecting? If I change the default port to 5001, the nginx configuration will not work as it expects the app to be runnning on port 5000?
 
     
     
    