mirror of
https://github.com/davila7/claude-code-templates.git
synced 2026-09-19 01:30:23 +08:00
dae5faa009
* migrate: Vercel → Cloudflare Pages + Workers para reducir costos ($110 → ~$0-5/mes) - Cambia adaptador Astro de @astrojs/vercel a @astrojs/cloudflare (mode: 'directory') - Agrega dashboard/wrangler.toml con nodejs_compat para compatibilidad total - Crea cloudflare-workers/crons/ Worker que reemplaza los cron jobs de Vercel (claude-code-check cada 30min, health-check cada 1h en vez de cada 15min) - Actualiza CI/CD: Vercel CLI → wrangler pages deploy (requiere CLOUDFLARE_API_TOKEN y CLOUDFLARE_ACCOUNT_ID en GitHub Secrets) - Elimina crons duplicados del proyecto legacy aitmpl (root vercel.json) - Quick win: agrega Cache-Control headers a components.json (86400s), plugins.json, trending-data.json y claude-jobs.json para cortar el costo de bandwidth de $53 Próximos pasos manuales (ver PR description): 1. Crear proyecto en Cloudflare Pages 2. Agregar secrets de Cloudflare en GitHub 3. Migrar env vars de Vercel a Cloudflare Dashboard 4. Deployar cloudflare-workers/crons con wrangler 5. Apuntar dominios a Cloudflare Pages * fix: nodejs_compat_v2 + react-dom/server.node alias para Cloudflare Workers - Cambia compatibility_flags de nodejs_compat a nodejs_compat_v2 - Agrega alias vite react-dom/server → react-dom/server.node para evitar MessageChannel error en module init time en Cloudflare Workers runtime - Agrega ssr.noExternal para bundlear react-dom y aplicar el alias * fix: revert compatibility_flags a nodejs_compat (estándar) nodejs_compat_v2 no es el flag primario. El fix real del MessageChannel error fue el alias vite react-dom/server → react-dom/server.node, no el cambio de flag. * fix: inject Cloudflare Pages runtime env into process.env via middleware Add Astro middleware that copies context.locals.runtime.env (Cloudflare Pages secrets) into process.env before each request, so API routes can use process.env.X as a unified pattern without changing the call sites. Also add || process.env.X fallbacks to all API routes/libs that were using import.meta.env exclusively (build-time only in Vite). Verified on staging: track-download-supabase, health-check, claude-code-check, collections, github/token all return correct responses.
59 lines
2.1 KiB
JSON
59 lines
2.1 KiB
JSON
{
|
|
"crons": [
|
|
{ "path": "/api/claude-code-check", "schedule": "*/30 * * * *" },
|
|
{ "path": "/api/health-check", "schedule": "*/15 * * * *" }
|
|
],
|
|
"headers": [
|
|
{
|
|
"source": "/(.*)",
|
|
"headers": [
|
|
{ "key": "X-Content-Type-Options", "value": "nosniff" },
|
|
{ "key": "X-Frame-Options", "value": "DENY" },
|
|
{ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" },
|
|
{ "key": "Strict-Transport-Security", "value": "max-age=31536000; includeSubDomains" },
|
|
{ "key": "Permissions-Policy", "value": "camera=(), microphone=(), geolocation=()" }
|
|
]
|
|
},
|
|
{
|
|
"source": "/components.json",
|
|
"headers": [
|
|
{ "key": "Access-Control-Allow-Origin", "value": "*" },
|
|
{ "key": "Access-Control-Allow-Methods", "value": "GET" },
|
|
{ "key": "Cache-Control", "value": "public, max-age=86400, stale-while-revalidate=3600" }
|
|
]
|
|
},
|
|
{
|
|
"source": "/trending-data.json",
|
|
"headers": [
|
|
{ "key": "Access-Control-Allow-Origin", "value": "*" },
|
|
{ "key": "Access-Control-Allow-Methods", "value": "GET" },
|
|
{ "key": "Cache-Control", "value": "public, max-age=3600, stale-while-revalidate=300" }
|
|
]
|
|
},
|
|
{
|
|
"source": "/plugins.json",
|
|
"headers": [
|
|
{ "key": "Access-Control-Allow-Origin", "value": "*" },
|
|
{ "key": "Access-Control-Allow-Methods", "value": "GET" },
|
|
{ "key": "Cache-Control", "value": "public, max-age=86400, stale-while-revalidate=3600" }
|
|
]
|
|
},
|
|
{
|
|
"source": "/claude-jobs.json",
|
|
"headers": [
|
|
{ "key": "Access-Control-Allow-Origin", "value": "*" },
|
|
{ "key": "Access-Control-Allow-Methods", "value": "GET" },
|
|
{ "key": "Cache-Control", "value": "public, max-age=3600, stale-while-revalidate=300" }
|
|
]
|
|
},
|
|
{
|
|
"source": "/api/(.*)",
|
|
"headers": [
|
|
{ "key": "Access-Control-Allow-Origin", "value": "*" },
|
|
{ "key": "Access-Control-Allow-Methods", "value": "GET, POST, PUT, PATCH, DELETE, OPTIONS" },
|
|
{ "key": "Access-Control-Allow-Headers", "value": "Content-Type, Authorization" }
|
|
]
|
|
}
|
|
]
|
|
}
|