// Container healthcheck. Works whether the app is serving http or self-signed https. const secure = ['1', 'true', 'yes', 'on'].includes(String(process.env.HTTPS_ENABLED).toLowerCase()); const port = process.env.PORT || 3000; const url = `${secure ? 'https' : 'http'}://127.0.0.1:${port}/healthz`; if (secure) process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; try { const res = await fetch(url, { signal: AbortSignal.timeout(4000) }); process.exit(res.ok ? 0 : 1); } catch { process.exit(1); }