From 9418d899e0c63740a6a5e6020fb2ef13082b735d Mon Sep 17 00:00:00 2001 From: Ben Allfree Date: Wed, 11 Oct 2023 06:27:51 -0700 Subject: [PATCH] enh: add PUBLIC_EDGE_APEX_DOMAIN to daemon --- .env-template | 3 +++ packages/daemon/src/constants.ts | 4 ++++ packages/daemon/src/services/ProxyService.ts | 6 +++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.env-template b/.env-template index 13838b3b..2b65ffa8 100644 --- a/.env-template +++ b/.env-template @@ -13,6 +13,9 @@ PUBLIC_APP_DOMAIN=app.pockethost.lvh.me # The domain name for the marketing/blog domain PUBLIC_BLOG_DOMAIN=pockethost.lvh.me +# The apex domain for the daemon +PUBLIC_EDGE_APEX_DOMAIN=pockethost.io + # The name of the central PocketHost database. This is both a subdomain and a file name. PUBLIC_APP_DB=pockethost-central diff --git a/packages/daemon/src/constants.ts b/packages/daemon/src/constants.ts index c09074e6..dc03116e 100644 --- a/packages/daemon/src/constants.ts +++ b/packages/daemon/src/constants.ts @@ -3,6 +3,10 @@ import { join } from 'path' import { env, envb, envi } from './util/env' export const PUBLIC_HTTP_PROTOCOL = env('PUBLIC_HTTP_PROTOCOL', 'https') export const PUBLIC_APP_DOMAIN = env('PUBLIC_APP_DOMAIN', `pockethost.test`) +export const PUBLIC_EDGE_APEX_DOMAIN = env( + 'PUBLIC_EDGE_APEX_DOMAIN', + `pockethost.test`, +) export const PUBLIC_APP_DB = env('PUBLIC_APP_DB', `pockethost-central`) export const DAEMON_PB_USERNAME = (() => { diff --git a/packages/daemon/src/services/ProxyService.ts b/packages/daemon/src/services/ProxyService.ts index fd9dc1ee..dc0128e5 100644 --- a/packages/daemon/src/services/ProxyService.ts +++ b/packages/daemon/src/services/ProxyService.ts @@ -1,4 +1,4 @@ -import { DAEMON_PORT, PUBLIC_APP_DOMAIN } from '$constants' +import { DAEMON_PORT, PUBLIC_EDGE_APEX_DOMAIN } from '$constants' import { Logger, SingletonBaseConfig, mkSingleton } from '@pockethost/common' import { isFunction } from '@s-libs/micro-dash' import { @@ -43,9 +43,9 @@ export const proxyService = mkSingleton(async (config: ProxyServiceConfig) => { const server = createServer(async (req, res) => { try { dbg(`Incoming request ${req.method} ${req.headers.host}/${req.url}`) - if (!req.headers.host?.endsWith(PUBLIC_APP_DOMAIN)) { + if (!req.headers.host?.endsWith(PUBLIC_EDGE_APEX_DOMAIN)) { warn( - `Request for ${req.headers.host} rejected because host does not end in ${PUBLIC_APP_DOMAIN}`, + `Request for ${req.headers.host} rejected because host does not end in ${PUBLIC_EDGE_APEX_DOMAIN}`, ) res.writeHead(502, { 'Content-Type': `text/plain`,