如何将<meta-httpequiv=“ContentSecurityPolicy”content=“upgradeinsurerequests”>添加到Flask引导温度

2024-05-19 17:03:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法通过浏览器获得预期结果,因为此请求已被阻止;内容必须通过HTTPS提供

我试着加上这个

{% block head %}
{{super()}}
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
{% endblock %}

对其他人有用

'https://matic.herokuapp.com/' was loaded over HTTPS, but requested an
insecure XMLHttpRequest endpoint
'http://matic.herokuapp.com/status/9092ba37-591e-4e73-b9e3-0ad9bef26cb1'.
This request has been blocked; the content must be served over HTTPS.

Tags: httpscomhttp内容浏览器contentblockherokuapp
1条回答
网友
1楼 · 发布于 2024-05-19 17:03:03

这意味着您将动态生成一个httpurl而不是https。当我看你的代码时,你在用

return jsonify(
       {}), 202, {
       'Location': url_for(
            'taskstatus', task_id=task.id)}`

创建动态url。你能把这个更新到

return jsonify(
       {}), 202, {
       'Location': url_for(
           'taskstatus', task_id=task.id, _external=True, _scheme='https')}`

并以结果回应。不是url_for中的差异

相关问题 更多 >