Share via

Container Instance running Spring Boot CORS Error

Anonymous
2022-12-12T10:28:37.49+00:00

So I am running a Container Instance with docker that loads a Spring Boot backend to which I am supposed to be able to make API calls, but I am getting a CORS error.

Access to fetch at 'http://[Azure Container Instance Public IP]:8080/api/puzzle/get/3a2a1397-2a7e-4df9-8f27-16671f3cbd61/0' from origin 'http://localhost:3000' 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.

For my CORS configuration in Spring Boot I have allowed origins localhost:3000, [My local machine public IP] and [My local machine public IP]:3000. and my React application sends forward the origin http://localhost:3000.

I am using a React application to connect to the Azure service, but it does not work. When I copy the exact same set up to my local machine and port forward everything, I am getting no issues at all. Ports 80 and 8080 are enabled on Container Instance in Azure.

Why does Azure give me these issues?

Azure Container Instances

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.