Mohammed Tahir
Mohammed Tahir

Reputation: 21

CORS Error for GET Request with Credentials in Django and React on Localhost Setup (Works with POST)

Introduction

I'm working on a Django backend with a React frontend, where I'm facing a CORS issue specifically for GET requests with credentials enabled. The POST requests work fine, but GET requests fail with a CORS error on the preflight request.

Setup and Background

Problem

Code Samples

Error Message

The following CORS error appears in Chrome and Safari (but it properly works in Opera):

Console error for the get request via axios to django local development server

Attempts to Fix

Question

  1. Why would CORS work with POST but not with GET in this setup, especially when everything works in Opera?

  2. Are there any configurations or additional middleware I need to handle CORS for preflight requests on GET for Chrome and Safari?

Upvotes: 0

Views: 44

Answers (0)

Related Questions