spring Security下,X-Frame-Options默認為DENY,非Spring Security環境下,X-Frame-Options的默認大多也是DENY:
DENY:瀏覽器拒絕當前頁面加載任何Frame頁面
SAMEORIGIN:frame頁面的地址只能為同源域名下的頁面
ALLOW-FROM:origin為允許frame加載的頁面地址。
解決辦法:disable x-frame-options 選項
http.authorizeRequests() .antMatchers("/").permitAll() // .anyRequest().authenticated() // 其他地址的訪問均需驗證權限 .and() .formLogin() .loginPage("/login.html") // 登錄頁 .failureUrl("/login-error.html").permitAll() // 禁用frameOptions .and().headers().frameOptions().disable().and() .logout() .logoutSuccessUrl("/public/test/index.html"); ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = http.authorizeRequests(); registry.requestMatchers(CorsUtils::isPreFlightRequest).permitAll();