[2017해커톤] Spring cross domain 이슈 처리

[해커톤] Spring Boot / Cross Domain 이슈

해결법 1. @CrossOrigin [code lang=text] @RequestMapping(value = Constant.URI_CATEGORY_TYPE_API) @CrossOrigin public String getCategoryType(){ List categoryType = new ArrayList<>(); categoryType.add(CategoryType.Date); categoryType.add(CategoryType.Random); categoryType.add(CategoryType.Repo); return categoryType.toString(); } [/code] 해결법 2. JavaConfig [code lang=text] @Configuration public class WebConfiguration { @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping(“/**”); } }; } } [/code] 참고 https://spring.io/guides/gs/rest-service-cors/ https://spring.io/blog/2015/06/08/cors-support-in-spring-framework


  TOC