Given a React app using Vite that tries to fetch data from an external service https://api.infomaniak.com/1/ai/product_id_here/openai/chat/completions
I’m getting the error
Access to fetch at
‘https://api.infomaniak.com/1/ai/product_id_here/openai/chat/completions’
from origin ‘http://localhost:5173’ has been blocked by CORS policy:
Response to preflight request doesn’t pass access control check: 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.
So I thought I should use Nginx mapped to port 8080 first but unfortunately I’m getting the same error when starting the Docker container and accessing http://localhost:8080
.
I thought I could disable CORS then but I was told that makes things even worse.
What is wrong or missing?