【发布时间】:2017-12-02 15:09:19
【问题描述】:
我已经在 Heroku 上部署了一个应用程序,但问题是当我的应用程序发送电子邮件时,它没有在 URL 中附加我的服务器名称:
content = Content("text/html", verification_email.format(user["first_name"],
url_for("register.display_register_form",
token=token.decode("utf-8"), external=True)))
但我在电子邮件中收到的链接是:
http:///register_account/DnsJpXw_QIcPYeDHEg_fipB2kRiJBUj2RI6I9cI4Yl4w6K9ohbZRMVqBInuV0aOsBT4Zqt69X8MfhNfnys4s-DAQmgu1OPBwmSQnzAELvdcCyiZtkJGSY8_dQ799FOewtBDkvqR1D8XHmvVxgaVqbwSjdEBnvFsBBHMQCic%3D/verify?external=True
这个网址有问题:
- 它不是 https,它应该是因为它是 heroku 上的主机
- 服务器名称仅出现在 URL 中
///就像服务器名称为空时一样
我应该怎么做才能获得正确的 URL https://my-server-name/register_account...?
编辑
我尝试在我的 config.py 文件中设置以下变量:
SERVER_NAME = "http://my-server-58140.herokuapp.com"
它在我的路径中产生了错误,我无法访问任何 URL,例如,以前可以访问以下 URL,但是在定义我的 SERVER_NAME 时它不再存在:
http://my-server-58140.herokuapp.com/home
编辑
我的烧瓶应用程序已配置:
SERVER_NAME = os.environ.get('SERVER_NAME')
DEBUG = True
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
环境变量在我的本地主机上设置为0.0.0.0:5000,在我的生产服务器上设置为:my-server-58140.herokuapp.com
【问题讨论】:
标签: python python-3.x heroku flask