Opened 4 months ago

Closed 4 months ago

Last modified 4 months ago

#35573 closed Bug (invalid)

CORS Policy Error with Specific Data in React and Django Application

Reported by: Mahira Owned by:
Component: CSRF Version: 5.0
Severity: Normal Keywords:
Cc: Mahira Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Mahira)

CORS Policy Error with Specific Data in React and Django Application

I'm experiencing an issue with CORS policy in my React frontend and Django backend application. The error message I'm receiving is:

Access to fetch at backend URL' from origin 'frontend URL' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I have configured all the CORS Configuration in settings.py

MIDDLEWARE = [

'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',

]

CORS_ORIGIN_ALLOW_ALL = True

CORS_ALLOW_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']

CORS_ALLOW_HEADERS = [

'accept',
'accept-encoding',
'authorization',
'content-type',
'dnt',
'origin',
'user-agent',
'x-csrftoken',
'x-requested-with',

]
Installed apps also 'corsheader' is added

The problem is i am getting this issue for only one data not for all data

Change History (4)

comment:1 by Mahira, 4 months ago

Description: modified (diff)

comment:2 by Jacob Walls, 4 months ago

Resolution: invalid
Status: newclosed

Hi. Your report doesn't provide enough information to suggest that Django is at fault. You may find it more advantageous to consult support channels as a first avenue.

comment:3 by Mahira, 4 months ago

Description: modified (diff)

I am getting CORS Issue even after i configured cors-header lib its happening for Some Specific Data not for all the Data

For Example if I have edit/1 -> Data id i can able to edit i am getting 200 Status

IF I am editing edit/2 -> its throwing CORS Issue in console and its given 403 Status what might be the issue

comment:4 by Natalia Bidart, 4 months ago

Hello Mahira! It seems like you might be facing difficulties understanding how Django works. There are several user support channels available. Please refer to TicketClosingReasons/UseSupportChannels for ways to get help.

Note: See TracTickets for help on using tickets.
Back to Top