본문 바로가기
개발자의 삶/스프링부트

CORS 해결

by 나.R.D.(Rule Destoryer) 2020. 9. 26.

외부에서 api 서버용으로 스프링부트 프로젝트를 구축했을 때, 호출 시, 도메인이 달라 cors 문제가 발생하게 된다.

 

해결 방법은 아래와 같다.

 

...
@Controller
@CrossOrigin("http://localhost:3000")
@RequestMapping("/api/test")
public class TestController {
	...
}

호출되는 localhost:3000 을 허용해주겠다는 의미이다.

 

#참고

spring.io/guides/gs/rest-service-cors/

반응형

댓글