enh: add PUBLIC_EDGE_APEX_DOMAIN to daemon

This commit is contained in:
Ben Allfree 2023-10-11 06:27:51 -07:00
parent 473bd17dd8
commit 9418d899e0
3 changed files with 10 additions and 3 deletions

View File

@ -13,6 +13,9 @@ PUBLIC_APP_DOMAIN=app.pockethost.lvh.me
# The domain name for the marketing/blog domain # The domain name for the marketing/blog domain
PUBLIC_BLOG_DOMAIN=pockethost.lvh.me 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. # The name of the central PocketHost database. This is both a subdomain and a file name.
PUBLIC_APP_DB=pockethost-central PUBLIC_APP_DB=pockethost-central

View File

@ -3,6 +3,10 @@ import { join } from 'path'
import { env, envb, envi } from './util/env' import { env, envb, envi } from './util/env'
export const PUBLIC_HTTP_PROTOCOL = env('PUBLIC_HTTP_PROTOCOL', 'https') export const PUBLIC_HTTP_PROTOCOL = env('PUBLIC_HTTP_PROTOCOL', 'https')
export const PUBLIC_APP_DOMAIN = env('PUBLIC_APP_DOMAIN', `pockethost.test`) 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 PUBLIC_APP_DB = env('PUBLIC_APP_DB', `pockethost-central`)
export const DAEMON_PB_USERNAME = (() => { export const DAEMON_PB_USERNAME = (() => {

View File

@ -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 { Logger, SingletonBaseConfig, mkSingleton } from '@pockethost/common'
import { isFunction } from '@s-libs/micro-dash' import { isFunction } from '@s-libs/micro-dash'
import { import {
@ -43,9 +43,9 @@ export const proxyService = mkSingleton(async (config: ProxyServiceConfig) => {
const server = createServer(async (req, res) => { const server = createServer(async (req, res) => {
try { try {
dbg(`Incoming request ${req.method} ${req.headers.host}/${req.url}`) 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( 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, { res.writeHead(502, {
'Content-Type': `text/plain`, 'Content-Type': `text/plain`,