본문 바로가기
개발(라이브러리,프레임워크)/Spring boot

CORS 설정

by zieunee 2021. 7. 2.
반응형

 

백엔드에서 CORS설정하기 

@Configuration
public class WebAppConfiguration implements WebMvcConfigurer{

	private AuthInterceptor myInterceptor;
	
	@Autowired
	public WebAppConfiguration(AuthInterceptor myInterceptor){
		this.myInterceptor = myInterceptor;
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(myInterceptor)
				.addPathPatterns("/**");
	}

	@Override
	public void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/**")
		.allowedOrigins("*");

	} //여기!! 모든 url요청 허용 (특정것만 허용하려면 url 을 적어줘야한다.
}

 

반응형