django - Django,Heroku,DisallowedHost 在 / 但主机在允许的主机列表中
问题描述
我有一个部署到 Heroku 的 Django 应用程序,但是当我尝试访问它时,我被禁止,主机错误说 Heroku 主机 URL 不在允许的主机中,但它实际上是。
错误
Invalid HTTP_HOST header: 'scr-rivendell.herokuapp.com'. You may need to add 'scr-rivendell.herokuapp.com' to ALLOWED_HOSTS.
设置:
ALLOWED_HOSTS = ['localhost', '127.0.0.1:8000', 'https://scr-rivendell.herokuapp.com/']
我检查了外壳以确保我是对的:
>>> import django
>>> django.conf.settings.ALLOWED_HOSTS
['localhost', '127.0.0.1:8000', 'https://scr-rivendell.herokuapp.com/']
解决方案
诸如http://
prhttps://
之类的 Url Scheme 不是主机地址的一部分。
将您的 ALLOWED_HOSTS 更新到下面应该可以。
ALLOWED_HOSTS = ['localhost', '127.0.0.1:8000', 'scr-rivendell.herokuapp.com']
推荐阅读
- windows - 在 Windows awk 上转义反斜杠和括号
- c# - 正则表达式应该在两点之间取文本并写其他内容
- windows - 如果程序终止,则释放映射到用户空间的设备内存
- javascript - 如何让firefox mobile检测搜索引擎?
- c++ - 如果您不知道相应的类,如何检查方法是否相同?
- node.js - Node.js - Google Cloud Speech API - 事件监听器问题
- bash - 如何在不丢失格式的情况下在多行表中换行?
- javascript - 我需要比较多个数组并注销 JavaScript 中的差异。这是任何可能长度的嵌套数组
- c - 在没有分段错误的情况下访问分配的内存
- c - 我有神秘的 C 代码女巫在同一个测试用例中有不同的行为,我认为这是 coodblock 问题