frpm https://docs.spring.io/spring-boot/docs/2.0.3.RELEASE/reference/htmlsingle/#boot-features-cors
27.1.13 CORS Support
Cross-origin resource sharing (CORS) is a W3C specification implemented by most browsers that lets you specify in a flexible way what kind of cross-domain requests are authorized, instead of using some less secure and less powerful approaches such as IFRAME or JSONP.
As of version 4.2, Spring MVC supports CORS. Using controller method CORS configuration with @CrossOrigin
annotations in your Spring Boot application does not require any specific configuration. Global CORS configuration can be defined by registering a WebMvcConfigurer
bean with a customizedaddCorsMappings(CorsRegistry)
method, as shown in the following example:
@Configuration public class MyConfiguration { @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/**"); } }; } }
'IT > 스프링' 카테고리의 다른 글
intelliJ 에서 스프링 mvc 시작하기 (0) | 2012.03.27 |
---|---|
스프링 스테레오 타입... 어노테이션 , annotation !!!! (0) | 2012.03.21 |
Autowired / Resource 차이... !!!!! (0) | 2012.03.15 |
Bean .. 빈 객체 스캔하여 빈 등록 (0) | 2012.02.29 |
스프링이 객체를 생성하는 형태? (0) | 2012.02.22 |