CORS issues in Django App

I have 2 workspaces. 1 for a BE app in Django and 1 for a FE app in React. Everything works ok until I want to send a header in my request, I have an CORS error saying the Access-Control-Allow-Origin header is not present in the preflight request. I have everything configured on my Django App, I added the headers in the allow header setting. The custom headers works just fine in Thunderclient or postman from both my PC and FE workspace. The requests without any header from my FE app is also fine. I really need a header, any header for my JWT Authentication.
Thanks!

Hi @Dragos-Gabriel_Bizu - I think you are running into the same problem as outlined here: CORS Issue When Migrating Project to IDX Does @ksat’s suggestion unblock you.

If not, this seems like something we’ll need to address better inside IDX.

Thanks,
Kirupa

@kirupa Yes, I saw that and it actually helps with requests without headers, if I add any header the CORS error appears again. I also tried to remove the credentials: 'include' and add the Authorization: Bearer <idx token> header, but no luck with this too. I will try next to move both FE and BE into the same workspace, hope this will work.
Thanks!

1 Like

Keep us posted. Taking a few steps back, IDX should do a better job here without requiring you (or others) to change a workflow that either already works locally or on other cloud-based IDEs. So, we have some work to do here, and I hope to share some positive updates on this in the near future!

2 Likes

Actually, I think you will probably get the same error. I was previously working with the same setup as you, using two workspaces. Even after switching to using the same workspace for both the frontend and backend, I encountered the same issue

@Yel-kobi Yes, you were right, even in the same workspace the request fails with cors error if I add any aditional header. As you said in your thread, might be an issue related with google VM verifications, but I did not find anything about any setting to fix the issue in idx.