I have deploy an application on Heroku but the problem is when my application send email it doesn't append the name of my server in the URL:
content = Content("text/html", verification_email.format(user["first_name"],
url_for("register.display_register_form",
token=token.decode("utf-8"), external=True)))
But the link I'm receiving in my email is:
http:///register_account/DnsJpXw_QIcPYeDHEg_fipB2kRiJBUj2RI6I9cI4Yl4w6K9ohbZRMVqBInuV0aOsBT4Zqt69X8MfhNfnys4s-DAQmgu1OPBwmSQnzAELvdcCyiZtkJGSY8_dQ799FOewtBDkvqR1D8XHmvVxgaVqbwSjdEBnvFsBBHMQCic%3D/verify?external=True
I have problems with this URL:
///
like if the server name was blankWhat should I do to have the correct URL https://my-server-name/register_account...
?
EDIT
I tried to set in my config.py file with the following variable to:
SERVER_NAME = "http://my-server-58140.herokuapp.com"
It generated errors in my path and I couldn't access any URL for example, the following one could be access before but when defining my SERVER_NAME
it didn't anymore:
http://my-server-58140.herokuapp.com/home
EDIT
My flask application is configured:
SERVER_NAME = os.environ.get('SERVER_NAME')
DEBUG = True
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
Where the environnement variable is set to 0.0.0.0:5000
on my localhost and: my-server-58140.herokuapp.com
on my production server
To generate the correct URL, these two Flask configuration values need to be set:
SERVER_NAME
to the name of your website,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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With