From dcb23b0a8674f2d1e6edef35cee4fa6cc078fc60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Sat, 25 Jul 2026 13:43:57 +0000 Subject: [PATCH] server: allowed origin from PUBLIC_URL; repoint web assets to the new domain origin-validation: the production web origin now reads from PUBLIC_URL (.env), e.g. https://officer.pastilhas.dev, instead of a hardcoded domain; drop alpha.officer.dev. officer-web/index.html: point og:image/favicon/manifest/etc. at the new domain (served locally from public/). Co-Authored-By: Claude Opus 4.8 --- src/apps/officer-web/index.html | 16 ++++++++-------- src/servers/_middlewares/origin-validation.ts | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/apps/officer-web/index.html b/src/apps/officer-web/index.html index e1d874ba..a33cabe1 100644 --- a/src/apps/officer-web/index.html +++ b/src/apps/officer-web/index.html @@ -10,25 +10,25 @@ - - + + - + - + - - - - + + + + diff --git a/src/servers/_middlewares/origin-validation.ts b/src/servers/_middlewares/origin-validation.ts index 2d11b3b3..025def78 100644 --- a/src/servers/_middlewares/origin-validation.ts +++ b/src/servers/_middlewares/origin-validation.ts @@ -1,11 +1,20 @@ import type { MiddlewareHandler } from 'hono'; import * as errors from '../custom-errors'; -const { PUBLIC_BUILD_ENV, EXPO_PUBLIC_CLIENT_ORIGIN } = process.env; +const { PUBLIC_BUILD_ENV, PUBLIC_URL, EXPO_PUBLIC_CLIENT_ORIGIN } = process.env; + +// The allowed production web origin comes from PUBLIC_URL in .env (e.g. https://officer.pastilhas.dev), +// not a hardcoded domain. +const PUBLIC_ORIGIN = (() => { + try { + return PUBLIC_URL ? new URL(PUBLIC_URL).origin : undefined; + } catch { + return undefined; + } +})(); const WEB_ORIGINS: Record = { - alpha: ['https://alpha.officer.dev'], - production: ['https://app.officer.dev', 'https://edge.officer.dev'], + production: PUBLIC_ORIGIN ? [PUBLIC_ORIGIN] : [], }; const CHROME_EXTENSIONS: string[] = [