mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-08-17 18:25:42 +02:00
[eric] electron: exempt same-origin navigations in main-window will-navigate so a reload (Restart tour) on the prod 4173 origin isn't re-opened as a recursive browser card
This commit is contained in:
+9
-1
@@ -1220,7 +1220,15 @@ function createWindow() {
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
if (isDev && url.startsWith('http://localhost:3000')) return;
|
||||
// Same-origin navigations are the app's own routing (reload, hash routes),
|
||||
// never an external link to pop into a browser card. The old port-specific
|
||||
// exemptions missed prod (renderer on 127.0.0.1:4173, not localhost:3000 or
|
||||
// file://), so a reload, e.g. Restart tour, got intercepted and re-opened
|
||||
// as a browser card loading the app itself (the recursive nested window).
|
||||
try {
|
||||
const current = mainWindow.webContents.getURL();
|
||||
if (current && new URL(url).origin === new URL(current).origin) return;
|
||||
} catch (_) {}
|
||||
if (url.startsWith('file://')) return;
|
||||
event.preventDefault();
|
||||
mainWindow.webContents.send('webview-new-window', url, mainWindow.webContents.id);
|
||||
|
||||
Reference in New Issue
Block a user