This is from spring docs. I added this code and it does redirect to https. But when trying to log in (send a post request) from inside frontend, it can not find expected header 'csrf token' (this was working correctly before adding redirect code).
@Bean
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http
// ...
.redirectToHttps(withDefaults());
return http.build();
}