I'm trying to send a POST request from my React frontend using Axios
import axios from 'axios'
axios.post('http://server:port/auth/login', {
username: 'admin',
password: 'MY_PASSWORD',
}, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}
})
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error.response)
});
No matter what I do, I get a 400 Bad Request in response stating:
"username":[This field is required],
"password":[This field is required]
I am using the Django REST framework in my Django Backend for authentication.
Everything works fine using Insomnia but any requests through React results in a "Bad Request"
django-cors-headers has been installed and configured as well.