From d4cb99fd916413ca7859fd9252a0ce75f58b147a Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Tue, 26 Jun 2018 12:57:42 +0200 Subject: [PATCH] fix(devtools): patch webrequest to fix devtools Fix an incompatibility between electron 2.x and devtools by patching the electron webRequest handler. See https://github.com/electron/electron/issues/13008#issuecomment-400261941 Fix #490 --- app/main.dev.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/main.dev.js b/app/main.dev.js index d775dd7e..d6a2e6b1 100644 --- a/app/main.dev.js +++ b/app/main.dev.js @@ -10,7 +10,7 @@ * * */ -import { app, BrowserWindow, ipcMain, dialog } from 'electron' +import { app, BrowserWindow, ipcMain, dialog, session } from 'electron' import path from 'path' import fs from 'fs' import split2 from 'split2' @@ -343,6 +343,21 @@ app.on('ready', async () => { mainWindow.webContents.send('successfullyCreatedWallet') } }) + + // HACK: patch webrequest to fix devtools incompatibility with electron 2.x. + // See https://github.com/electron/electron/issues/13008#issuecomment-400261941 + session.defaultSession.webRequest.onBeforeRequest({}, (details, callback) => { + if (details.url.indexOf('hack') !== -1) { + callback({ + redirectURL: details.url.replace( + '7accc8730b0f99b5e7c0702ea89d1fa7c17bfe33', + '57c9d07b416b5a2ea23d28247300e4af36329bdc' + ) + }) + } else { + callback({ cancel: false }) + } + }) }) app.setAsDefaultProtocolClient('lightning')