springBoot springSecurty x-frame-options deny

參考:https://blog.csdn.net/whiteforever/article/details/73201586

           https://blog.csdn.net/davylee2008/article/details/61420751

           https://blog.csdn.net/fl_zxf/article/details/51100599

          https://developer.mozilla.org/zh-CN/docs/Web/HTTP/X-Frame-Options

修改nginx 配置添加,把下面這行添加到 'http', 'server' 或者 'location' 的配置中:add_header X-Frame-Options SAMEORIGIN;

光添加這句根本就沒有用。然後有去修改後臺

在集成了WebSecurityConfigurerAdapter 類裏面的configure方法添加

httpSecurity.headers().frameOptions().sameOrigin(); 我是這樣寫的,

也可以直接將headers移除這樣寫httpSecurity.headers().frameOptions().disable();

然後在你請求的那個controller裏面添加response.setHeader("X-Frame-Options", "SAMEORIGIN"); 就ok了。

我的項目是這樣少一個都不行。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章