fix: auto gmail serve path for tailscale

This commit is contained in:
Peter Steinberger
2025-12-24 21:56:17 +00:00
parent 79870472e1
commit cffac6e11a
3 changed files with 75 additions and 6 deletions

View File

@@ -152,14 +152,25 @@ export function resolveGmailHookRuntimeConfig(
servePortRaw > 0
? Math.floor(servePortRaw)
: DEFAULT_GMAIL_SERVE_PORT;
const servePath = normalizeServePath(
overrides.servePath ?? gmail?.serve?.path,
);
const servePathRaw = overrides.servePath ?? gmail?.serve?.path;
const hasExplicitServePath =
typeof servePathRaw === "string" && servePathRaw.trim().length > 0;
const tailscaleMode =
overrides.tailscaleMode ?? gmail?.tailscale?.mode ?? "off";
// When exposing the push endpoint via Tailscale, the public path is stripped
// before proxying; use "/" internally unless the user set a path explicitly.
const servePath = normalizeServePath(
tailscaleMode !== "off" && !hasExplicitServePath ? "/" : servePathRaw,
);
const tailscalePathRaw = overrides.tailscalePath ?? gmail?.tailscale?.path;
const tailscalePath = normalizeServePath(
overrides.tailscalePath ?? gmail?.tailscale?.path ?? servePath,
tailscaleMode !== "off" && !tailscalePathRaw
? hasExplicitServePath
? servePathRaw
: DEFAULT_GMAIL_SERVE_PATH
: tailscalePathRaw ?? servePath,
);
return {