
h2-console을 사용하려는 과정에서 위와같은 상황이 발생함.
Security 설정 관련 문제로 보였고, 원인을 파악함.
h2-console은 frame을 사용하여 내요을 표시함. Spring Scurity는 기본 속성으로 X-Frame-Options 헤더를 설정함. 따라서 렌더링이 차단될 수 있음.
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.csrf(auth -> auth.disable());
http.headers(headers -> headers.frameOptions(frameOptions -> frameOptions.sameOrigin()));
http.authorizeHttpRequests(auth -> auth
.requestMatchers("/h2-console/**").permitAll()
.anyRequest().permitAll());
return http.build();
}
http.headers로 frameOptions를 sameOrigin() 설정해주니 정상 동작함.
그렇군요 그런 문제가 있엇군요