How to run and test the template app (apps/template) and the bodegacat integration on your machine. Admin routes work without Cloudflare Access in dev.
Use pnpm from the repository root. Stripe keys belong in
apps/template/.env. Integration source ispackages/bodegacat.
Deploying to Cloudflare (KV, Pages env vars, wrangler, Access): see examples/deploy/cloudflare-pages/README.md. This doc stays focused on local astro dev and monorepo workflows.
-
Install
pnpm install
-
Environment
cp env.example apps/template/.env
Edit
apps/template/.envwith your Stripe test keys and, for admin dev bypass:STRIPE_SECRET_KEY=sk_test_... STRIPE_PUBLISHABLE_KEY=pk_test_... STRIPE_WEBHOOK_SECRET=whsec_... NODE_ENV=development
-
Run
pnpm dev
Open
http://localhost:4321.
In dev (NODE_ENV=development or import.meta.env.DEV), middleware skips Cloudflare Access, sets a mock user (dev@localhost), and shows a Development mode indicator on screen.
In production, /admin/* expects Cloudflare Access (see the deploy guide, section 6).
astro dev is not the same as running the built Worker. To use /admin on local wrangler without Cloudflare Access:
-
Add to
apps/template/.dev.vars(copy fromapps/template/dev.vars.example):BODEGACAT_ADMIN_LOCAL_BYPASS=true
Wrangler injects this at runtime (keep Stripe keys here too for preview).
-
Run
pnpm --filter @bodegacat/template preview(orpnpm previewfrom repo root). -
Open
http://localhost:8787/admin(or the URL wrangler prints). The bypass applies only when the request host is loopback (localhost,127.0.0.1, etc.) — not on a real deployed hostname. -
Never set
BODEGACAT_ADMIN_LOCAL_BYPASSin production Cloudflare env.
Useful routes:
| Path | Purpose |
|---|---|
/admin |
Dashboard |
/admin/products |
Product list |
/admin/products/new |
Create product |
/api/admin/products |
List/create (API) |
/api/stripe-webhook |
Webhook endpoint |
Products can be active in Stripe but not published to the public catalog (metadata.bodegacat_published=false). The public site (/, /shop, /shop/[slug]) is prerendered (astro build) and shows only published items from Stripe at build time, plus getSiteConfig() (defaults + optional SITE_* env) — not KV. Draft preview is SSR under /preview, /preview/shop, /preview/shop/[slug] — same staff auth as /admin (dev bypass locally; Cloudflare Access in production).
| Environment | How to open preview |
|---|---|
| Local dev | Visit /preview or /preview/shop (middleware uses the same dev user as admin). |
| Production | Cloudflare Access must allow /preview* (mirror your /admin policy). |
The admin nav links to /preview when you have draft products. Uncheck Published on storefront until you are ready; then redeploy (or use the webhook build hook below) so the static catalog updates.
Changing products or prices in Stripe does not update prerendered HTML until the next astro build.
- Recommended (batch edits): leave
STRIPE_WEBHOOK_AUTO_DEPLOYunset orfalse. Stripe webhooks still verify and log, but they do not trigger a deploy on every product save. When staff are happy, use Admin → Deploy live site (callsBUILD_HOOK_URL) for one production build — same as a git push tomain. - Optional: set
STRIPE_WEBHOOK_AUTO_DEPLOY=trueif you wantproduct.*/price.*Stripe events to callBUILD_HOOK_URLautomatically (can mean many deploys).
That rebuild bakes catalog from Stripe at build time and SITE_* from the build environment. KV (admin UI) does not update prerendered / or /shop HTML; align with CLAUDE.md / .cursor/rules/bodegacat-storefront-architecture.mdc.
Set BUILD_HOOK_URL in production to your Pages deploy hook URL (see the Cloudflare deploy guide).
Use the Stripe Dashboard (test mode) for products and webhooks. Required product metadata (bodegacat_active, slug, prices, etc.) is documented in VARIATION_SYSTEM.md and summarized on the repository README.
For card numbers and test mode behavior, see Stripe testing.
| Issue | What to check |
|---|---|
| Admin not loading | NODE_ENV=development in .env, pnpm dev from repo root, browser console |
| Stripe / empty shop | Keys match test mode, products exist with correct metadata (see VARIATION_SYSTEM) |
Draft not on /shop |
Expected until published or use /preview/shop; public /shop is static until rebuild |
| Type / lint errors | pnpm run typecheck, pnpm run lint from repo root |
Staging/production, Cloudflare Access, and Stripe live mode are covered in the Cloudflare deploy guide.
- Stripe Test Mode
- Astro dev toolbar
- Product variations & metadata
- Dogfooding a separate store repo against a local
packages/bodegacatclone: Developing the package with a separate store app in the repository README