【问题标题】:Iframe is not working then pointing Heroku URLiframe 不工作然后指向 Heroku URL
【发布时间】:2017-06-10 20:07:07
【问题描述】:
我有一个 Python Django 应用程序在 https://dj-node-project.herokuapp.com/catalog/ 上运行,当我将它放入 iframe 时,我看到一个空白页。我需要在 Heroku 上启用“iframe”设置吗?
<iframe src="https://dj-node-project.herokuapp.com/catalog/">
<p>Your browser does not support iframes.</p>
</iframe>
【问题讨论】:
标签:
python
django
heroku
iframe
【解决方案1】:
您可以删除中间件,如下所述
你也可以使用装饰器
from django.views.decorators.clickjacking import xframe_options_exempt
@xframe_options_exempt
def ok_to_load_in_a_frame(request):
Django 不允许使用 django 网站作为 iframe 标签。因为django有中间件
'django.middleware.clickjacking.XFrameOptionsMiddleware',
不允许使用 iframe 标记将 django 网站加载到另一个网站。它在页面加载时检查 SAMEORIGIN。
你有
阅读有关此主题的完整信息https://docs.djangoproject.com/en/1.11/ref/clickjacking/