I faced the same issue a while ago, you can use electron debugger API to get the response body and the headers, currently webRequest can't get the response body.
Here's the answer: https://stackoverflow.com/a/66675347/13752696
But basically:
try {
mainWindow.webContents.debugger.attach('1.3');
} catch (err) {
console.log('Debugger attach failed: ', err);
}
mainWindow.webContents.debugger.on('detach', (event, reason) => {
console.log('Debugger detached due to: ', reason);
});
mainWindow.webContents.debugger.on('message', (event, method, params) => {
if (method === 'Network.responseReceived') {
console.log(params.response.url);
mainWindow.webContents.debugger.sendCommand('Network.getResponseBody', { requestId: params.requestId }).then(function(response) {
console.log(response);
});
}
});
mainWindow.webContents.debugger.sendCommand('Network.enable');