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[] = [