简体   繁体   English

CSRF 验证失败。 请求中止

[英]CSRF verification failed. Request aborted

The only help towards this I can get is我能得到的唯一帮助是

It was working all day and all of a sudden this error starting popping up.它整天都在工作,突然间这个错误开始弹出。

"Reason given for failure: CSRF cookie not set." “失败原因:未设置 CSRF cookie。”

Turning debug to TRUE gives me nothing more.将 debug 设置为 TRUE 仅此而已。 I see no errors in nginx either.我在 nginx 中也没有看到任何错误。

I have set CSRF_TRUSTED_ORIGINS我已经设置了 CSRF_TRUSTED_ORIGINS

DEBUG = False调试 = 假

CSRF_TRUSTED_ORIGINS = ['http://.*', 'http://example.com', 'http://example.com'] CSRF_TRUSTED_ORIGINS = ['http://.*', 'http://example.com', 'http://example.com']

HTTPS Settings HTTPS 设置

SESSION_COOKIE_SECURE = True SESSION_COOKIE_SECURE = 真

CSRF_COOKIE_SECURE = False CSRF_COOKIE_SECURE = 假

SECURE_SSL_REDIRECT = False SECURE_SSL_REDIRECT = 假

HSTS Settings HSTS 设置

SECURE_HSTS_SECONDS = 31536000 SECURE_HSTS_SECONDS = 31536000

SECURE_HSTS_PRELOAD = True SECURE_HSTS_PRELOAD = 真

SECURE_HSTS_INCLUDE_SUBDOMAINS = True SECURE_HSTS_INCLUDE_SUBDOMAINS = 真

FIXED:固定的:

I checked gunicorn status using:我使用以下方法检查了 gunicorn 状态:

 sudo systemctl status gunicorn

It gave me an error regarding my IP address needed adding to allowed hosts.它给了我一个关于我的 IP 地址需要添加到允许的主机的错误。

If error still persists:如果错误仍然存在:

sudo systemctl restart gunicorn

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM