From 8cfb5449fd0750df5eb1d5c4aebb2905542810d7 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 17 Dec 2024 11:04:35 +1300 Subject: [PATCH] open external links in default web browser instead of electron --- electron/main.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/electron/main.js b/electron/main.js index cb7c7b5..a520d54 100644 --- a/electron/main.js +++ b/electron/main.js @@ -108,6 +108,25 @@ app.whenReady().then(async () => { }, }); + // open external links in default web browser instead of electron + mainWindow.webContents.setWindowOpenHandler(({ url }) => { + + // open internal MeshChat urls starting with http://localhost in electron + // this is needed for pages such as call.html that open in a new window + if(url.startsWith("http://localhost")){ + return { + action: "allow", + }; + } + + // fallback to opening any other url in external browser + shell.openExternal(url); + return { + action: "deny", + }; + + }); + // navigate to loading page await mainWindow.loadFile(path.join(__dirname, 'loading.html'));