mirror of
https://github.com/tale/headplane.git
synced 2026-08-19 17:36:19 +00:00
feat: allow a public headscale URL separate from the main one
This commit is contained in:
@@ -15,6 +15,7 @@ import log from '~/utils/log'
|
||||
export interface HeadplaneContext {
|
||||
debug: boolean
|
||||
headscaleUrl: string
|
||||
headscalePublicUrl?: string
|
||||
cookieSecret: string
|
||||
integration: IntegrationFactory | undefined
|
||||
|
||||
@@ -56,12 +57,18 @@ export async function loadContext(): Promise<HeadplaneContext> {
|
||||
const { config, contextData } = await checkConfig(path)
|
||||
|
||||
let headscaleUrl = process.env.HEADSCALE_URL
|
||||
let headscalePublicUrl = process.env.HEADSCALE_PUBLIC_URL
|
||||
|
||||
if (!headscaleUrl && !config) {
|
||||
throw new Error('HEADSCALE_URL not set')
|
||||
}
|
||||
|
||||
if (config) {
|
||||
headscaleUrl = headscaleUrl ?? config.server_url
|
||||
if (!headscalePublicUrl) {
|
||||
// Fallback to the config value if the env var is not set
|
||||
headscalePublicUrl = config.public_url
|
||||
}
|
||||
}
|
||||
|
||||
if (!headscaleUrl) {
|
||||
@@ -76,6 +83,7 @@ export async function loadContext(): Promise<HeadplaneContext> {
|
||||
context = {
|
||||
debug,
|
||||
headscaleUrl,
|
||||
headscalePublicUrl,
|
||||
cookieSecret,
|
||||
integration: await loadIntegration(),
|
||||
config: contextData,
|
||||
@@ -84,6 +92,10 @@ export async function loadContext(): Promise<HeadplaneContext> {
|
||||
|
||||
log.info('CTXT', 'Starting Headplane with Context')
|
||||
log.info('CTXT', 'HEADSCALE_URL: %s', headscaleUrl)
|
||||
if (headscalePublicUrl) {
|
||||
log.info('CTXT', 'HEADSCALE_PUBLIC_URL: %s', headscalePublicUrl)
|
||||
}
|
||||
|
||||
log.info('CTXT', 'Integration: %s', context.integration?.name ?? 'None')
|
||||
log.info('CTXT', 'Config: %s', contextData.read
|
||||
? `Found ${contextData.write ? '' : '(Read Only)'}`
|
||||
|
||||
Reference in New Issue
Block a user