- I have a spring boot application
- I would like to enable HSTS
I added the documented settings to my SecurityConfiguration (see below), but HSTS header is not appearing.
What am I doing wrong?
@Slf4j
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.headers()
.httpStrictTransportSecurity()
.includeSubDomains(true)
.preload(false)
.maxAgeInSeconds(31536000);
I can't find the header in Chrome Developer Tools (F12 -> Network -> Headers -> Response Header) when accessing the page nor when testing with official site https://gf.dev/hsts-test