问题一
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'
网友评论