Home > OS >  CSRF verification failed. Request aborted
CSRF verification failed. Request aborted

Time:12-17

Been working on my live server all day and just got it working, admin was working fine, i cleared cookies and suddenly i got the following error, and no fixes seem to be helping me. My website does have SSL yet so its still http(dont know if this has anything to do with it?) enter image description here

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


# HTTPS Settings
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = False
SECURE_SSL_REDIRECT = False

# HSTS Settings

SECURE_HSTS_SECONDS = 31536000
SECURE_HSTS_PRELOAD = True
SECURE_HSTS_INCLUDE_SUBDOMAINS = True

This is the only form on my website that requires csrf_token and as you can see it already has it. enter image description here

CodePudding user response:

Do you have CsrfViewMiddleware in your MIDDLEWARE_CLASSES setting? Are you accessing the site non-securely (seems so) then it could not work. Try to disable CSRF_COOKIE_SECURE, CSRF_COOKIE_HTTPONLY and SESSION_COOKIE_SECURE and you will see it will work.

  • Related