NWJS - “拒绝在框架中显示...错误
我试图在iframe中从本地网络上的设备显示网页。但是我得到:
“拒绝显示'http://192.168.1.252/'在框架中,因为它将'x-frame-options'设置为'Sameorigin'。 /(1)
我遵循了有关设置节点帧 https://docs.nwjs.io/en/latest/for%20users/advanced/security%20in%20nw.js/
我的清单文件:
{
"name": "AppApp",
"description": "AppApp",
"version": "0.0.1",
"icon": "icons/app.icns",
"main": "html/main.html",
"chromium-args": "--enable-logging=stderr --enable-spell-checking",
"window": {
"toolbar": false,
"width": 800,
"height": 500
},
"nodejs": true,
"node-remote": "*://*"
}
html:
<iframe src="http://192.168.1.252/"></iframe>
iframe 我需要做更多的事情来绕过相同的原始政策?
I am attempting to display a webpage from a device on my local network in an iframe. However I get:
"Refused to display 'http://192.168.1.252/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.", source: chrome-error://chromewebdata/ (1)
I have followed the documentation regarding setting up node frames https://docs.nwjs.io/en/latest/For%20Users/Advanced/Security%20in%20NW.js/
My manifest file:
{
"name": "AppApp",
"description": "AppApp",
"version": "0.0.1",
"icon": "icons/app.icns",
"main": "html/main.html",
"chromium-args": "--enable-logging=stderr --enable-spell-checking",
"window": {
"toolbar": false,
"width": 800,
"height": 500
},
"nodejs": true,
"node-remote": "*://*"
}
iframe HTML:
<iframe src="http://192.168.1.252/"></iframe>
Is there more that I need to do to bypass the same origin policy?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个错误,这里提供了解决方法:
https://github.com/ NWJS/nw.js/essess/7049
“ X-Frame-Options的解决方法应与NWFAKETOP属性一起使用。”
根据错误,如果
x-frame-options:deny
没有问题,则仅当问题存在时,只有x-frame-options:Sameorigin
和nwfaketop
必须使用解决方案。(请注意,我观察到,在铬 - 弧中使用 - 可访问 - 网状安全性导致该页面无法正确加载,因此我将其删除。)
This is a bug, and a workaround is provided here:
https://github.com/nwjs/nw.js/issues/7049
"The X-Frame-Options workaround should be used in an iframe with the nwfaketop property."
According to the bug, if
X-Frame-Options: Deny
there isn't a problem, it is only ifX-Frame-Options: sameorigin
when the problem exists, and thenwfaketop
workaround must be used.(Note, I observed that using --disable-web-security in chromium-args caused the page to not load properly, so I removed it.)
不要 ---禁用 - web-security ,但请这样做:
步骤1:将下面的脚本保存为 background.js 和将此文件移至项目的文件夹...
2:在您的清单中。
步骤 >在您的清单中
。重新加载令人讨厌的网站,最后笑! :)
Don't ---disable-web-security, but do this instead:
Step 1: Save the script below as background.js and move this file to your project's folder...
Step 2: In your manifest.json ensure you correctly accommodate this line...
Step 3: In your manifest.json ensure you include "webRequest" among the other Chrome APIs etc...
Step 4: Now compile your app, reload the offending site and have the last laugh! :)