Django Cors headers Error after changing region

issamarHOBBY

a month ago

I recently encountered a long response of my website project build with drf and reactjs and postgres as database

I found that all my project is hosted in us west and I am in Algeria so I changed the region to Amesterdam because it s the closest to me So after migration of all my services I found my backend (django) respond with CORS Headers error even I didn t change anything in my project so what's Happened And How I can solve the problem

thank's in advance

$10 Bounty

2 Replies

ogbcodePRO

a month ago

this is a typescript fix you just have to add the frontend origin to your allowed origins

// Define allowed origins statically (no environment switching)

const origins = [

'https://example.com',

'https://dashboard.example.com',

'https://api.example.com',

'https://checkout.example.com',

'https://admin.example.com',

'http://localhost:3000',

'http://localhost:5173',

'http://localhost:5174'

]

// Enable Cross-Origin Resource Sharing (CORS)

app.enableCors({

origin: origins, // Set allowed origins

methods: ['GET', 'POST', 'PATCH', 'DELETE', 'PUT', 'OPTIONS'], // Allowed HTTP methods

allowedHeaders: ['Content-Type', 'Authorization', 'x-csrf-token'], // Allowed request headers

credentials: true, // Allow cookies and credentials in CORS requests

})


issamarHOBBY

a month ago

but the front end origin didn"t change every variable stayed as it was but I have this Cors Headers Origin
maybe is matter of time ?