Skip to content

WebConfiguration

Hanaux edited this page Dec 5, 2022 · 1 revision

CORS 문제가 지속 발생할시,,, Config 폴더에 WebMvcConfig.java 생성

import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration public class WebMvcConfig implements WebMvcConfigurer {

@Override
public void addCorsMappings(CorsRegistry registry){
    registry.addMapping("/**")
            .allowedOrigins("http://localhost:3000")
            .allowedMethods("OPTIONS", "GET", "POST", "PUT", "DELETE");
}

}

Clone this wiki locally