Search code examples
cookiesdjango-settingssamesiterecaptcha-v3

Recaptcha Samesite Cookie Error with Django 4.0.4


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?


Solution

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