I have deployed 3 docker containers - for the database, the backend (Spring boot) and the frontend (Angular). However, when I am visiting the website (Google Cloud VM), I am getting CORS error for all the requests to backends. The backend is run on 8080.
I am getting CORS when I am visiting the IP:80
Why is this happening? What is the workaround?
Here is the way I have used CrossOrigin in the controller.
@CrossOrigin("*")
@RestController
@RequestMapping("/api")
public class CustomerController {
Any help is appreciated.
You are not allowed to call URLs from your scripts that are not found under the same domain that you page was rendered:
For security reasons, browsers restrict cross-origin HTTP requests initiated from scripts. For example, XMLHttpRequest and the Fetch API follow the same-origin policy. This means that a web application using those APIs can only request resources from the same origin the application was loaded from, unless the response from other origins includes the right CORS headers.
Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
You actually have 3 Options:
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments