error cors with django and frontend

diegoainext
HOBBY

6 months ago

Disclaimer: i have two accounts and in my another account is deployed this web as www.energialimpia.com.bo, but i need to deploy in this account and i'm using energia-limpia.up.railway.app, but i got an error CORS:

Access to fetch at 'https://clean-energy-backend.up.railway.app/api/homes/1' from origin 'https://energia-limpia.up.railway.app' 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 got this error, when i want to navigate to https://energia-limpia.up.railway.app, and i configured the Cors in my backend Django settings
CORS_ALLOWED_ORIGINS = [ "http://localhost:3000", "https://www.energialimpia.com.bo", "https://localhost:3000", "https://127.0.0.1:3000", "http://127.0.0.1:3000", "https://clean-energy-frontend-test.up.railway.app", "https://energia-limpia.up.railway.app", "https://www.clean-energy-frontend-test.up.railway.app", "https://www.energia-limpia.up.railway.app", ]

CSRF_TRUSTED_ORIGINS = ['https://clean-energy-backend.up.railway.app', 'https://cleanenergybackend.up.railway.app', 'https://www.cleanenergybackend.up.railway.app', 'https://clean-energy-frontend-test.up.railway.app', 'https://www.clean-energy-frontend-test.up.railway.app', 'https://energia-limpia.up.railway.app', 'https://www.energia-limpia.up.railway.app', 'https://www.energialimpia.com.bo', 'https://localhost:3000']

ALLOWED_HOSTS = ["localhost", "clean-energy-backend.up.railway.app", "cleanenergybackend.up.railway.app", "127.0.0.1", "clean-energy-frontend-test.up.railway.app", "energia-limpia.up.railway.app", "www.energialimpia.com.bo", "energialimpia.com.bo"]

and my railway Enviroment variable in my frontend is
NEXT_PUBLIC_BACKEND_URL="https://cleanenergybackend.up.railway.app"

i don't know why isn't redirecting to the right backend url and, i configured my settings to accepts that request

0 Replies

6 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 6 months ago