react 일 경우,
react ↔ springBoot 연동 : axios
기본 웹브라우저의 내장된 프로그램
인터넷 기본 보안 : ip , port 최초에 지정된 것과 달라지면
=> 해킹으로 기본인정되서 (블러킹 : 단절)처리됨
이것을 CORS 보안이라고 한다.
속성 | 특징 |
@Configuration | 자바클래스에 설정기능을 부여하는 어노테이션 |
allowedOrigins | 허용할 URI 설정 |
allowedMethods | 허용할 메서드 방식 |
기본 cors 설정
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
// 아래 url 허용
// TODO: 사용법 : .allowedOrigins("http://허용할IP:허용할Port" , ...)
.allowedOrigins("http://localhost:3000")
// Todo: 아래 추가해야 update, delete, insert, select 가 cors 문제가 안생김
.allowedMethods(
HttpMethod.GET.name(),
HttpMethod.POST.name(),
HttpMethod.PUT.name(),
HttpMethod.DELETE.name(),
HttpMethod.PATCH.name() // 수정할 때 쓰는 방식 PUT 과 유사
);
}
}
'SpringBoot > JPA' 카테고리의 다른 글
SpringBoot - JPA - @Query insert 문 (0) | 2023.10.27 |
---|---|
SpringBoot - JPA - Pageable 객체 (+ typeScript 예제) (0) | 2023.10.23 |
SpringBoot - Hard Delete 와 Soft Delete 개념 (0) | 2023.10.19 |
SpringBoot - JPA - 1 대 1 관계 (0) | 2023.10.19 |
SpringBoot - JPA - 조인 ( 1 대 다 관계 ) (0) | 2023.10.19 |