Setting Referrer-Policy in Spring Boot

  Kiến thức lập trình

I want to set HTTP headers in springboot. Specifically, I need to set “Referrer-Policy” to “same-origin”.

Therefore, I created the following class :

public class SecurityConfiguration {
    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http.headers(headers -> headers.frameOptions(frameOptions -> frameOptions.sameOrigin()));
        return http.build();
    }
} //  SecurityConfiguration

But when I look with wireshark at the preflight response (spring app -> browser), I can see that the “Referrer-Policy” is set to no-referrer.

Any idea ?

Thks in adv.

LEAVE A COMMENT