feat(browser): loopback allowlist with same-origin for local dev servers

Add a side-card preference 'browserAllowedLoopback' (comma-separated
host or host:port entries) that lets the sidebar browser navigate to
explicitly trusted loopback addresses. Bare hosts (localhost,
127.0.0.1) match every port; host:port entries match exactly.

Allowlisted local addresses additionally get the 'allow-same-origin'
sandbox token in the iframe: local dev servers (Vite etc.) need a real
origin for their module/HMR/fetch pipeline and would otherwise render
blank in the opaque-origin sandbox. The page stays cross-origin to the
GUI and to every other site.

The server-side browser.probe route mirrors the same allowlist so
probed local servers are not rejected as 'local addresses are not
probed'.
This commit is contained in:
trinhthiminh650-tech
2026-08-15 01:37:39 +08:00
parent 6f092a6b1a
commit 8014255541
8 changed files with 129 additions and 7 deletions
+6
View File
@@ -199,6 +199,12 @@ export function builtinTabs(ctx: Context): readonly TabDescriptor[] {
key: 'browserInterceptLinks',
title: () => t('settingsBrowserLinksTitle'),
desc: () => t('settingsBrowserLinksDesc'),
}, {
key: 'browserAllowedLoopback',
type: 'text',
title: () => t('settingsBrowserLoopbackTitle'),
desc: () => t('settingsBrowserLoopbackDesc'),
placeholder: t('settingsBrowserLoopbackPlaceholder'),
}],
},
createTab: (state) => ({