From the course: Complete Guide to Spring MVC

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

CORS

CORS

- [Instructor] CORS. As a developer, I'm sure you've encountered CORS, or cross-origin resource sharing, at some point. It's a common roadblock when dealing with cross-domain requests, so while adding Access-Control-Allow-Origin might seem like a quick fix, it's often not enough to fully address CORS issues. To take a quick one step back, what is CORS? So CORS is a security mechanism implemented in web browsers. It restricts how resources like APIs can be requested from a domain different from the one serving the web application. For example, let's say you have your front end being a React app running on local host 3000, whereas your back end is a Spring Boot app running on local host 8080. If the React app tries to access the Spring Boot API, the browser checks if the back end allows request from the front end origin. So the back end Spring Boot app is going to say, "Hey, can I take a request from this front end React app?" If not configured, the request will be blocked, and who is…

Contents