Refused to display ‘http://localhost:xxxx/‘ in a frame because it set ‘X-Frame-Options‘ to ‘deny‘.

项目场景:

springboot项目运行出现以下的提示:
在这里插入图片描述


原因分析:

Spring Security默认是将’X-Frame-Options’ 设置为 ‘DENY’
X-Frame-Options HTTP 响应头是用来给浏览器指示允许一个页面可否在 frame , iframe 或者 object 中展现的标记。网站可以使用此功能,来确保自己网站的内容没有被嵌到别人的网站中去,也从而避免了点击劫持 (clickjacking) 的攻击。


解决方案:

解决办法一

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    
    
    //授权
    @Override
    protected void configure(HttpSecurity http) throws Exception {
    
    
        //disable frameOptions检验
        http.headers().frameOptions().disable();
    }

}

猜你喜欢

转载自blog.csdn.net/qq_49023625/article/details/128947598
今日推荐