在开发环境中,我的浏览器(Yandex)将
OPTIONS
请求重定向(307)到 URL 的 https 版本,但由于我们没有设置 SSL,因此该请求会失败并显示错误 Response for preflight is invalid (redirect)
。OPTIONS
请求重定向(307)到 URL 的 https 版本,但由于我们没有设置 SSL,因此该请求会失败并显示错误 Response for preflight is invalid (redirect)
。我通过如下配置HSTS头解决了这个问题:
@Configuration
@EnableWebSecurity
public class SecurityConfigurer extends WebSecurityConfigurerAdapter {
...
@Override
protected void configure(HttpSecurity http) throws Exception {
...
http.headers().httpStrictTransportSecurity()
.maxAgeInSeconds(0)
.includeSubDomains(true);
}
}
http.headers().httpStrictTransportSecurity().disable()
对我也起作用。我正在使用Spring Boot 2.0.1.RELEASE并通过Chrome 66 DevTools验证了未发送HSTS头。 - sigint