From c859d5e677c4fac9459868be721ac7fe782a7094 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Mon, 16 Feb 2026 23:08:12 +0100 Subject: [PATCH] fix: pipeline --- docker-compose.yml | 2 +- middleware.ts | 2 +- scripts/check-og-images.ts | 17 ++++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d2c93837..6e602343 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,7 +28,7 @@ services: - "traefik.http.routers.${PROJECT_NAME:-klz-cables}.middlewares=${AUTH_MIDDLEWARE:-${PROJECT_NAME:-klz-cables}-ratelimit,${PROJECT_NAME:-klz-cables}-forward,${PROJECT_NAME:-klz-cables}-compress}" # Public Router (Whitelist for OG Images, Sitemaps, Health) - - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-public.rule=(${TRAEFIK_HOST_RULE:-Host(`${TRAEFIK_HOST:-klz-cables.com}`)}) && (PathPrefix(`/health`, `/sitemap.xml`, `/robots.txt`, `/manifest.webmanifest`, `/api/og`) || PathRegexp(`^/([a-z]{2}/)?opengraph-image$`) || PathRegexp(`^/([a-z]{2}/)?blog/opengraph-image$`) || PathRegexp(`^/sitemap(-[0-9]+)?\\.xml$`))" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-public.rule=(${TRAEFIK_HOST_RULE:-Host(`${TRAEFIK_HOST:-klz-cables.com}`)}) && (PathPrefix(`/health`, `/sitemap.xml`, `/robots.txt`, `/manifest.webmanifest`) || PathRegexp(`^/([a-z]{2}/)?api/og`) || PathRegexp(`^/([a-z]{2}/)?opengraph-image$`) || PathRegexp(`^/([a-z]{2}/)?blog/opengraph-image$`) || PathRegexp(`^/sitemap(-[0-9]+)?\\.xml$`))" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-public.entrypoints=${TRAEFIK_ENTRYPOINT:-web}" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-public.tls.certresolver=${TRAEFIK_CERT_RESOLVER:-}" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-public.tls=${TRAEFIK_TLS:-false}" diff --git a/middleware.ts b/middleware.ts index a6062bce..4debdb5a 100644 --- a/middleware.ts +++ b/middleware.ts @@ -19,7 +19,7 @@ export default function middleware(request: NextRequest) { pathname.startsWith('/stats') || pathname.startsWith('/errors') || pathname.startsWith('/health') || - pathname.startsWith('/api/og') || + pathname.includes('/api/og') || pathname.includes('opengraph-image') ) { return; diff --git a/scripts/check-og-images.ts b/scripts/check-og-images.ts index 790c3b25..c0632afd 100644 --- a/scripts/check-og-images.ts +++ b/scripts/check-og-images.ts @@ -22,17 +22,20 @@ async function verifyImage(path: string): Promise { console.log(`Checking ${url}...`); - if (response.status !== 200) { - throw new Error(`Status: ${response.status}`); - } - + const body = await response.text(); const contentType = response.headers.get('content-type'); - if (!contentType?.includes('image/png')) { - const body = await response.text(); + + if (response.status !== 200) { console.log(` Headers: ${JSON.stringify(Object.fromEntries(response.headers))}`); console.log(` Status Text: ${response.statusText}`); throw new Error( - `Status: ${response.status}. Content-Type: ${contentType}. Body preview: ${body.substring(0, 1000).replace(/\n/g, ' ')}...`, + `Status: ${response.status}. Body preview: ${body.substring(0, 1000).replace(/\n/g, ' ')}...`, + ); + } + + if (!contentType?.includes('image/png')) { + throw new Error( + `Content-Type: ${contentType}. Body preview: ${body.substring(0, 1000).replace(/\n/g, ' ')}...`, ); }