From main window i am using this code to open a window on click
pwin = new BrowserWindow({
width: 355,
height: 250
})
pwin.loadURL(`file://${__dirname}/players/jwplayer.html`);
// pwin.setMenu(null)
pwin.webContents.on('did-finish-load', () => {
pwin.webContents.send('link', link);
pwin.webContents.send('name', title);
});
on the new window i have a code to modify request headers
session.defaultSession.webRequest.onBeforeSendHeaders(['*://*./*'], (details, callback) => {
if (details.url.indexOf('okaystreamz') > -1) {
details.requestHeaders['User-Agent'] = 'tvingoplus@livetv.tvingo1Z!2018';
}
callback({
cancel: false,
requestHeaders: details.requestHeaders
})
});
When I am opening the pwin first time, its working. When I close it and open it again, I get this error
"Attempting to call a function in a renderer window that has been closed or released."
Any help will be appreciated