CORS Policy error

rildo691HOBBY

8 months ago

Hello guys,

Hope everything is going well with you.

I'm experiencing a problem when I try to send HTTP POST requests on my back-end, I have a deployment of my back-end on Railway built my NestJs and a deployment of my front-end on Vercel. Everytime I try a POST request to the server I get the error: Access to fetch at 'https://mercury-backend-production-6ee2.up.railway.app/suppliers' from origin 'https://mercury-frontend.vercel.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.

But in the meantime I allow all the methods from both my localhost and the production of the front-end, the weird thing is that the GET requests from the front-end work very well just the POST requests have an issue:

app.enableCors({
    origin: ['http://localhost:3000', 'https://mercury-frontend.vercel.app/'], 
    methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', 
    credentials: true, 
  }); 

I recently received an email saying:

Deploy Ran Out of Memory!

Uh oh. Your deployment for MySQL in tender-learning ran out of memory within the production environment and crashed.

But I don't think this is the problem. If you please have an idea of how I can fix this error I would appreciate your help.

Thank you.

Solved

1 Replies

rildo691HOBBY

8 months ago

I managed to solve it guys. Thank you.


Status changed to Solved brody 8 months ago