Home > Software engineering >  CSRF verification failed. Request aborted in http URL
CSRF verification failed. Request aborted in http URL

Time:02-01

enter image description here

In my login showing error when submit the form in http url but https url working fine.

my login form is ` {% csrf_token %} Please log in Or click here to register {% if msg %} Error Invalid credentials or inactive account. If you have registered please make sure to activate your account by clicking on the link sent to your email address. Please check your spam folder if you are unable to find the email. {% endif %}

      <input type="text"  name="email"
        placeholder="Email Address" required="" autofocus=""
        ng-model="loginEmail"></input> <input type="password"
         name="password" placeholder="Password"
        required="" ng-model="loginPwd"></input>

      <button  type="submit"
        ng-click="login(loginForm.username.$viewValue, loginForm.password.$viewValue)">Log in</button>
    </form>`

localhost working proper this code but live site not working in http. Also i add {% csrf_token %} in login form please someone help me!

CodePudding user response:

Add a {% csrf_token %} to your form. Should cover you for the issue.

CodePudding user response:

Add this option to the settings:

    CSRF_TRUSTED_ORIGINS = [
       'Url.com',
       'Url.com/',

    ]

You need to put your own website as a trusted origin since django 4.0.

CodePudding user response:

You will need to add this to your settings.py if you are using http:

CSRF_COOKIE_SECURE = False
  • Related