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
2 Replies
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://dashboard.example.com',
'https://checkout.example.com',
]
// 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
})
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 ?