url_for with _external=True on heroku doesn't append the server name on the URL url_for with _external=True on heroku doesn't append the server name on the URL python-3.x python-3.x

url_for with _external=True on heroku doesn't append the server name on the URL


To generate the correct URL, these two Flask configuration values need to be set:

  • SERVER_NAME to the name of your website,
  • and PREFERRED_URL_SCHEME to https.

See the documentation for url_for() and how to configure a Flask application.

EDIT: Additionally, the parameter in url_for should be _external and not external.