vue 使用 ifame 嵌套网页的时候报 Refused to display 'http://192.168.179.62:8781/' in a frame because it set 'X-Frame-Options' to 'deny'. 错误

<template lang="html">
  <div class="width:100%;height:500px;border:1px solid red;">
    <iframe name="myiframe"  id="myrame-record-query"  src="http://192.168.179.62:8781/login"  frameborder="0" align="middle"  width="100%"  height="700px"></iframe>
  </div>
</template>

这是被后端拒绝了,然后我百度了一下更改了 spring security 的配置

@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
   
    @Override
    protected void configure(HttpSecurity http) throws Exception {
         ...
        http.headers().frameOptions().sameOrigin();
    }
}

 结果又报下面的错误

 

这样设置应该是相同域名才可以访问。

然后 我用  http.headers().frameOptions().disable(); //禁用 

这样不同域名的都可以调用访问。

上面总算是解决了,因为IFRAME里面页面需要登录又报了以下的错误:

Blocked autofocusing on a <input> element in a cross-origin subframe.

...

最后还是在新页面打开页面算了

 

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐