Files
token-circles/worker/wrangler.jsonc
T
KomediruzeckiandGitHub c4133572ab fix: charted PDFs in server mode; iOS calendar-tap crash; working unsubscribe (#260)
* fix: charted PDFs in server mode; iOS calendar-tap crash; working unsubscribe page

Three user-reported issues:

- Reports: the Settings PDF downloads hit the worker's /api/reports/*-pdf in
  self-hosted mode, which can only produce text (Workers have no canvas) — the
  'Annual Financial Report' lost its charts on the dev domain. Rich PDFs are now
  always composed client-side (jsPDF + Chart.js worker); loadReportSource feeds
  the generators from IndexedDB in serverless mode or from the HTTP API
  (/api/transactions + /api/categories) in self-hosted mode. Verified: annual
  PDF ~1.9MB with charts vs the old ~4KB text-only.

- iOS 'script error' crash on bills-calendar day tap: the global ErrorBoundary
  escalated EVERY window error to a full-screen crash modal — including the
  opaque 'Script error.' fired by cross-origin scripts (Cloudflare Bot Fight
  Mode's injected /cdn-cgi/ challenge, extensions). Third-party/opaque errors
  are now logged but never take over the app; real same-origin errors still
  show the crash modal. Bonus: the day popover is a bottom sheet on phone
  widths (cell-anchored placement ran off-screen on lower calendar rows) and
  clamps to the viewport on desktop.

- Unsubscribe: the email footer linked the SPA origin (CORS_ORIGIN), so the
  click landed on the static-asset fallback — no page, and nobody was actually
  unsubscribed. New API_PUBLIC_ORIGIN var (dev + prod + local) targets the
  worker itself; the endpoint now renders a branded confirmation page, a
  distinct 'link not recognized' page for stale tokens (no fake success), and
  links back to the app. Re-enable any time under Settings, Notifications.

Worker: 49 tests (3 new unsubscribe). Frontend: 375 tests. Chromium-verified:
PDF size/magic-bytes, synthetic Script error./cdn-cgi events leave the app
alive while a real error still crashes properly, calendar bottom sheet fully
on-screen at 375x812.

* fix(dashboard): show the Views modal close X; drop redundant footer divider

The modal-close SVG had no width/height so it rendered 0x0 — the X was in the
DOM but invisible. Set it to 20x20 (and add aria-label). Also remove the
border-top divider above the Save & Close button in the widget settings footer.
2026-07-03 22:17:04 +02:00

102 lines
5.1 KiB
JSON

{
"$schema": "node_modules/wrangler/config-schema.json",
// Finance Manager API worker (Hono + D1 + R2). Two deploy environments — `dev`
// (dev.<domain>) and `prod` (app.<domain>) — plus local dev off the top-level bindings.
// Everything marked PLACEHOLDER must be filled before the matching deploy; local dev
// works with the placeholders as-is.
"name": "finance-manager-api",
"main": "src/index.ts",
"compatibility_date": "2026-06-26",
"compatibility_flags": ["nodejs_compat"],
"observability": { "enabled": true },
// The Cloudflare account that owns the Worker + D1 + R2. From `wrangler whoami`,
// or export CLOUDFLARE_ACCOUNT_ID instead of setting it here.
// "account_id": "PLACEHOLDER_ACCOUNT_ID",
// ── Top-level bindings = what `pnpm run dev` (LOCAL dev) uses ──────────────────
// `wrangler dev` runs against a LOCAL D1 + R2 (state under .wrangler/, keyed by the
// binding NAME), so the placeholder database_id is fine locally. Apply the schema once
// with `pnpm run d1:migrate:local`. The env.dev / env.prod blocks override these for
// the real deployments.
"d1_databases": [{ "binding": "DB", "database_name": "finance-manager", "database_id": "local" }],
"r2_buckets": [{ "binding": "RECEIPTS", "bucket_name": "finance-manager-receipts" }],
"vars": {
"APP_ENV": "development",
"GOOGLE_CLIENT_ID": "PLACEHOLDER.apps.googleusercontent.com",
"CORS_ORIGIN": "http://localhost:3800",
// Public origin of THIS worker (email links must point here, not at the SPA host)
"API_PUBLIC_ORIGIN": "http://localhost:8787",
},
"env": {
// ── DEV → api.dev.<domain> (deploy: pnpm run deploy:dev) ──────────────────
"dev": {
"name": "finance-manager-api-dev",
// API on its own subdomain so the session cookie is same-site with the app
// (SameSite=Lax + COOKIE_DOMAIN). tokencircles.com must be an active zone in this
// Cloudflare account; `deploy:dev` then provisions the api.dev.tokencircles.com DNS.
"routes": [{ "pattern": "api.dev.tokencircles.com", "custom_domain": true }],
"vars": {
"APP_ENV": "dev",
"GOOGLE_CLIENT_ID": "961447002903-p2gkcujs85svbuf4tpmvu1cj4ge1ivh3.apps.googleusercontent.com",
"CORS_ORIGIN": "https://dev.tokencircles.com",
"APP_ORIGINS": "https://dev.tokencircles.com",
"API_PUBLIC_ORIGIN": "https://api.dev.tokencircles.com",
"COOKIE_DOMAIN": ".dev.tokencircles.com",
"EMAIL_FROM": "Token Circles <hello@tokencircles.com>",
// Stripe per-tier Price ids (TEST mode for dev) — vars, NOT secret. STRIPE_SECRET_KEY +
// STRIPE_WEBHOOK_SECRET are SECRETS (wrangler secret put). Steps: dotfiles billing-setup.md.
"STRIPE_PRICE_BASIC_MONTHLY": "price_1Tnn1kRczc8qAc4q8GsNyKQp",
"STRIPE_PRICE_BASIC_ANNUAL": "price_1TnnKVRczc8qAc4qEaqRAIwL",
"STRIPE_PRICE_ADVANCED_MONTHLY": "price_1Tnn9yRczc8qAc4qOjczMNxF",
"STRIPE_PRICE_ADVANCED_ANNUAL": "price_1TnnLCRczc8qAc4q0ISY361o",
"STRIPE_PRICE_ULTIMATE_MONTHLY": "price_1TnnB3Rczc8qAc4qN9rzHYIq",
"STRIPE_PRICE_ULTIMATE_ANNUAL": "price_1TnnI1Rczc8qAc4qzqUzzODg",
},
"d1_databases": [
{
"binding": "DB",
"database_name": "finance-manager-dev",
"database_id": "7a785adc-c378-43fa-b812-171319b81f22",
},
],
"r2_buckets": [{ "binding": "RECEIPTS", "bucket_name": "finance-manager-receipts-dev" }],
"triggers": {
// Budget alerts Mon 09:00 UTC; spending report twice monthly (1st + 15th) 10:00 UTC.
// NB: cron day-of-month and day-of-week are OR'd, so the old "1-7,15-21 * 4" fired on every
// day in those ranges AND every Thursday. Day-of-week is now "*" and the report is idempotent
// per half-month period (reminder_dedup), so a re-fire can't double-send.
"crons": ["0 9 * * 1", "0 10 1,15 * *"],
},
},
// ── PROD → api.<domain> (deploy: pnpm run deploy:prod) ────────────────────
"prod": {
"name": "finance-manager-api",
// Uncomment for the prod deploy (api.tokencircles.com). Dev is being brought up first.
// "routes": [{ "pattern": "api.tokencircles.com", "custom_domain": true }],
"vars": {
"APP_ENV": "production",
"GOOGLE_CLIENT_ID": "PLACEHOLDER.apps.googleusercontent.com",
"CORS_ORIGIN": "https://app.tokencircles.com",
"APP_ORIGINS": "https://app.tokencircles.com",
"API_PUBLIC_ORIGIN": "https://api.tokencircles.com",
"COOKIE_DOMAIN": ".tokencircles.com",
},
"d1_databases": [
{
"binding": "DB",
"database_name": "finance-manager",
"database_id": "PLACEHOLDER_PROD_D1_DATABASE_ID",
},
],
"r2_buckets": [{ "binding": "RECEIPTS", "bucket_name": "finance-manager-receipts" }],
},
},
// Secrets (NEVER in vars/here): JWT_SECRET, GOOGLE_CLIENT_SECRET.
// Set per env: pnpm run secret:dev / pnpm run secret:prod
// Locally they live in .dev.vars (see .dev.vars.example).
}