From bcbc4523e4b60fc78c9c51d1c6640af8d1c80539 Mon Sep 17 00:00:00 2001 From: Marco Kunz <6626615+wrthwhl@users.noreply.github.com> Date: Mon, 19 Jan 2026 17:35:01 +0100 Subject: [PATCH] fix: add console deploy target, fix gitignore, add CORS for preview URLs --- .gitignore | 5 ++++- apps/analytics/src/index.ts | 19 +++++++++++++------ apps/console/project.json | 7 +++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index c4c47c3..5b75a47 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,7 @@ Thumbs.db /letters # Auto-generated Next.js file -next-env.d.ts \ No newline at end of file +next-env.d.ts + +# Wrangler +.wrangler/ diff --git a/apps/analytics/src/index.ts b/apps/analytics/src/index.ts index dba9193..5a89ba3 100644 --- a/apps/analytics/src/index.ts +++ b/apps/analytics/src/index.ts @@ -12,12 +12,19 @@ const app = new Hono<{ Bindings: Bindings }>(); app.use( '/api/*', cors({ - origin: [ - 'https://marco.wrthwhl.cloud', - 'https://console.wrthwhl.cloud', - 'http://localhost:3000', - 'http://localhost:3001', - ], + origin: (origin) => { + const allowed = [ + 'https://marco.wrthwhl.cloud', + 'https://console.wrthwhl.cloud', + 'http://localhost:3000', + 'http://localhost:3001', + ]; + // Allow exact matches + if (allowed.includes(origin)) return origin; + // Allow Cloudflare Pages preview URLs + if (origin.endsWith('.wrthwhl-console.pages.dev')) return origin; + return null; + }, allowMethods: ['GET', 'POST', 'OPTIONS'], allowHeaders: ['Content-Type'], credentials: true, diff --git a/apps/console/project.json b/apps/console/project.json index 6a29866..016fd50 100644 --- a/apps/console/project.json +++ b/apps/console/project.json @@ -36,6 +36,13 @@ "dev": false } } + }, + "deploy": { + "executor": "nx:run-commands", + "options": { + "command": "pnpm exec wrangler pages deploy dist/apps/console/.next --project-name wrthwhl-console --branch main --commit-dirty=true" + }, + "dependsOn": ["build"] } } }