From aa16c290ad91eba635694c6c4415b1f4d294cf77 Mon Sep 17 00:00:00 2001 From: brian91292 <8050523+brian91292@users.noreply.github.com> Date: Tue, 23 May 2023 13:51:32 -0500 Subject: [PATCH] make custom protocol handler work in dev mode --- electron/app.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/electron/app.ts b/electron/app.ts index 7256700..759d08f 100644 --- a/electron/app.ts +++ b/electron/app.ts @@ -621,7 +621,19 @@ function setupApp() { app.on('activate', function() { if (mainWindow === null) createWindow(); }); - app.setAsDefaultProtocolClient('sidequest'); + // remove so we can register each time as we run the app. + app.removeAsDefaultProtocolClient('sidequest'); + + // If we are running a non-packaged version of the app && on windows + if (process.env.NODE_ENV === 'dev' && process.platform === 'win32') { + console.log('Running in dev mode'); + // Set the path of electron.exe and your app. + // These two additional parameters are only available on windows. + app.setAsDefaultProtocolClient('sidequest', process.execPath, [path.resolve(process.argv[1])]); + } else { + console.log('Running in production'); + app.setAsDefaultProtocolClient('sidequest'); + } app.on('open-url', function(event, url) { event.preventDefault(); });