electron js, cant use an iframe

hi, i need to embed a twitch clip for a project of my own, and i want to use electron the ifram is working when the html is simply opened in the browser but with electron i've on one side an error in the console:
(node:1012) electron: Failed to load URL: https://clips.twitch.tv/embed?clip=<idduclip>&parent=127.0.0.1&autoplay=true&muted=false with error: ERR_BLOCKED_BY_RESPONSE
(node:1012) electron: Failed to load URL: https://clips.twitch.tv/embed?clip=<idduclip>&parent=127.0.0.1&autoplay=true&muted=false with error: ERR_BLOCKED_BY_RESPONSE
and on the other side in the dev tools:
Refused to frame 'https://clips.twitch.tv/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors http://127.0.0.1:* https://127.0.0.1:*".
Refused to frame 'https://clips.twitch.tv/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors http://127.0.0.1:* https://127.0.0.1:*".
thanks for your help
3 Replies
Jochem
Jochem2y ago
the CSP is set by the host, in this case clips.twitch.tv, and tells the browser that it doesn't want to be embedded in any pages hosted on localhost
roulès
roulèsOP2y ago
problem solved, i added
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
callback({
responseHeaders: {
...details.responseHeaders,
'Content-Security-Policy': [
"frame-src https://clips.twitch.tv"
]
}
})
})
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
callback({
responseHeaders: {
...details.responseHeaders,
'Content-Security-Policy': [
"frame-src https://clips.twitch.tv"
]
}
})
})
after
win.loadFile('index.html')
win.loadFile('index.html')
thx
Jochem
Jochem2y ago
ah, that's good to know!
Want results from more Discord servers?
Add your server