The following code works for Springboot 3.3.4 and Spring Security 6.3.3.
@Bean
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http.csrf(csrf -> csrf.ignoringRequestMatchers(new AntPathRequestMatcher("/api/**"))).build();
}