diff --git a/app/utils/headscale.ts b/app/utils/headscale.ts index 18d9d14..b85741a 100644 --- a/app/utils/headscale.ts +++ b/app/utils/headscale.ts @@ -20,6 +20,22 @@ export class FatalError extends Error { } } +export async function healthcheck() { + const context = await loadContext(); + const prefix = context.headscaleUrl; + log.debug('APIC', 'GET /health'); + + const health = new URL('health', prefix); + const response = await fetch(health.toString(), { + headers: { + Accept: 'application/json' + } + }) + + // Intentionally not catching + return response.status === 200; +} + export async function pull(url: string, key: string) { if (!key || key === 'undefined' || key.length === 0) { throw new Error('Missing API key, could this be a cookie setting issue?');