Django With ReactJs

 

Solving CSRF issue on React With Django (Running on Django Server)
npm install js-cookie --save
import Cookies from 'js-cookie'

const csrftoken = Cookies.get('csrftoken') // Cookies from Django Domain

    const loginRequest = async () => {
        await Axios({
            method: "post",
            url: `/api/api-auth/login/`,
            headers: { 'X-CSRFToken': csrftoken },
            data: {}
        }).then((res) => {
            console.log(res.data);
        })
    }
Fetch CSRF Token from Django Server:
django.middleware.csrf.get_token(request)

Send emails with Django and Gmail , a better way :

https://dev.to/abderrahmanemustapha/how-to-send-email-with-django-and-gmail-in-production-the-right-way-24ab

Comments

Popular posts from this blog

Generate SHA-1 and SHA-256 for Debug and Release android app

Transfer file to Server and vice versa

How to Import and Export MySQL Database Command line in Linux