I have added @CrossOrigin(origins = "*") annotation at the class level to my controller in the Spring Boot app, and I am still getting this error when I make an HTTP GET request from Angular to the Spring Boot app (listening on port 9000). Here is the error I get from Chrome.
Access to XMLHttpRequest at 'http://localhost:9000/employee/all' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I've found
@CrossOriginto be extremely finicky. You can try using just@CrossOriginwithout any parameters as Alexander suggested.You can also try adding a custom
CorsFilterBean to the class where you callSpringApplication.run(). That way you've essentially got full control over the filter and can add/remove methods if necessary.Something like this: