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"] } } }