DRF giving error on frontend but not REST client

Hi everyone. I have build an api which accepts a CSV on POST request and then sends the result in JSON. The thing is that there is no error when i send the POST request using Insomnia REST client with only one header of Content-Type but i am getting “CSRF verification failed. Request aborted.” when sending the POST request from browser.

When you post from the browser, you’ll be using session based authentication, which enforces CSRF checks.

You’ll need to make sure the CSRF token is correctly set.

There’s a topic page in the DRF docs for this:

https://www.django-rest-framework.org/topics/ajax-csrf-cors/

Give that a read. I’m sure it’ll help you solve your issue.

Kind regards, Carlton

2 Likes

Hi! Thank you for replying and yes it did help.