From 2eb71d5fdd4a389a1e9b151becb0824fa6b7055b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Art=D1=91m?= <470045+yart@users.noreply.github.com> Date: Tue, 21 Apr 2026 23:08:04 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20l?= =?UTF-8?q?oopback=20origin=20=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=BD=D1=8B?= =?UTF-8?q?=D0=BC=20=D0=B4=D0=BB=D1=8F=20push=20VAPID=20(#944)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/server/lib/notifications/push-runtime.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/web/server/lib/notifications/push-runtime.js b/packages/web/server/lib/notifications/push-runtime.js index 2cdf1930..58106c83 100644 --- a/packages/web/server/lib/notifications/push-runtime.js +++ b/packages/web/server/lib/notifications/push-runtime.js @@ -1,5 +1,15 @@ const PUSH_SUBSCRIPTIONS_VERSION = 1; +const isLoopbackHttpOrigin = (value) => { + if (typeof value !== 'string') { + return false; + } + + return value.startsWith('http://localhost') + || value.startsWith('http://127.0.0.1') + || value.startsWith('http://[::1]'); +}; + export const createPushRuntime = (deps) => { const { fsPromises, @@ -241,7 +251,7 @@ export const createPushRuntime = (deps) => { const originEnv = process.env.OPENCHAMBER_PUBLIC_ORIGIN; if (typeof originEnv === 'string' && originEnv.trim().length > 0) { const trimmed = originEnv.trim(); - if (trimmed.startsWith('http://localhost')) { + if (isLoopbackHttpOrigin(trimmed)) { return 'mailto:openchamber@localhost'; } return trimmed; @@ -252,7 +262,7 @@ export const createPushRuntime = (deps) => { const stored = settings?.publicOrigin; if (typeof stored === 'string' && stored.trim().length > 0) { const trimmed = stored.trim(); - if (trimmed.startsWith('http://localhost')) { + if (isLoopbackHttpOrigin(trimmed)) { return 'mailto:openchamber@localhost'; } return trimmed;