David Henson
David Henson

Reputation: 397

CSRF verification failed. Request aborted

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

Upvotes: 3

Views: 4298

Answers (2)

David Henson
David Henson

Reputation: 397

SOLVED

By adding the ip from my domain to the allowed hosts and trusted origins.

Upvotes: 3

Leonardo Di Lella
Leonardo Di Lella

Reputation: 116

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.

Upvotes: 0

Related Questions