From 3d7e939fccff346873c535c3d0f7937133c3da61 Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Thu, 4 Jun 2026 15:16:16 +0200 Subject: [PATCH] fix: handle app.pubpub.org redirect in caddy directly --- core/lib/server/errors.ts | 2 +- infra/Caddyfile | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/lib/server/errors.ts b/core/lib/server/errors.ts index 2e0d35651d..c51ff6bace 100644 --- a/core/lib/server/errors.ts +++ b/core/lib/server/errors.ts @@ -90,7 +90,7 @@ export const tsRestHandleErrors = async ( error: unknown, req: TsRestRequest ): Promise => { - const [_err, body] = req.bodyUsed ? [null, undefined] : await tryCatch(await req.json()) + const [_err, body] = req.bodyUsed ? [null, undefined] : await tryCatch(req.json()) if (error instanceof RequestValidationError) { logger.error({ err: error.body, input: body }) return TsRestResponse.fromJson( diff --git a/infra/Caddyfile b/infra/Caddyfile index d3ea92dd59..b32f430105 100644 --- a/infra/Caddyfile +++ b/infra/Caddyfile @@ -15,6 +15,23 @@ } } +# cannot be handled by simple redirects at eg cloudflare level +# would strip credentials +app.pubpub.org { + encode gzip + + handle /api/* { + reverse_proxy platform:3000 { + # present the canonical hostname to the app + header_up Host {$PUBSTAR_HOSTNAME} + } + } + + handle { + redir https://{$PUBSTAR_HOSTNAME}{uri} 301 + } +} + :80 { respond "OK" 200 }