美文网首页
iframe的跨域访问

iframe的跨域访问

作者: 领带衬有黄金 | 来源:发表于2019-09-28 18:29 被阅读0次

问题一

Refused to display
http://192.168.0.140:8000/bigdata/index/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
原因分析:由于iframe是容易被劫持的浏览器嵌套框架。浏览器会对iframe特殊处理

问题二

Invalid 'X-Frame-Options' header encountered when loading 'http://192.168.0.140:8000/bigdata/pdf/5EGhHqo9T99s4cvc0dka': 'ALLOW-FROM 
http://192.168.0.123:8080' is not a recognized directive. The header will be ignored.
原因分析:设置错误,需要设置为 ALLOWALL

最终处理:

resp = HttpResponse(pdf_data, content_type="application/pdf")
    # iframe 嵌套问题,类似于同源问题,但担心被劫持,需要服务器端
    resp['X-Frame-Options'] = 'ALLOWALL'

相关文章

网友评论

      本文标题:iframe的跨域访问

      本文链接:https://www.haomeiwen.com/subject/jmutpctx.html