recaptcha samesite cookie错误与django 4.0.4

发布于 2025-02-06 18:59:45 字数 731 浏览 2 评论 0原文

我在我的Django项目中包括了recaptcha v3,但面临此错误:

“指示是否在跨站点请求中发送cookie 指定其Samesite属性“

我尝试按照 django-检查cookie cookies' a>,甚至提到

一次

CSRF_COOKIE_SAMESITE = "random"

解决问题。代码>

然后我收到了一个更细微的错误 -

标记跨站点cookie是安全的,以便在跨站点上下文中设置它们

,我添加了csrf_cookie_secure = true,根据 docs ,但它一无所获。我仍然面临完全相同的错误。我该如何解决?

I have included Recaptcha v3 in my Django project but am faced with this error:

"Indicate whether to send a cookie in a cross-site request by
specifying its SameSite attribute"

I have tried following the answer in Django - check cookies's "SameSite" attribute and even referred to the docs, but I haven't been able to solve the problem.

First, I entered

CSRF_COOKIE_SAMESITE = "random"

in settings.py to check if it would be recognized and cause an error and it did, so I changed it to

CSRF_COOKIE_SAMESITE = "none"

Then I received a more nuanced error -

Mark cross-site cookies as Secure to allow setting them in cross-site contexts

Next, I added CSRF_COOKIE_SECURE = True as per the docs, but it achieves nothing. I still face the exact same error as with nothing at all. How can I solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

屋檐 2025-02-13 18:59:45

就我目前的理解而言,不可能在非HTTPS网站上拥有安全的cookie。

To the extent of my current understanding, it is not possible to have secure cookies on a non-https website.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文