Skip to content

Fix dashboard 500: route API calls via service binding - #10

Merged
tbjers merged 1 commit into
mainfrom
fix/dashboard-same-zone-fetch
Jun 24, 2026
Merged

Fix dashboard 500: route API calls via service binding#10
tbjers merged 1 commit into
mainfrom
fix/dashboard-same-zone-fetch

Conversation

@tbjers

@tbjers tbjers commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Pages server-side fetch calls to coverage-tracker.zerostash.org/api/* were bypassing Worker route matching (Cloudflare same-zone fetch behaviour), landing on Pages instead and returning 404
  • Add a WORKER service binding in dashboard/wrangler.jsonc so the Pages function calls the Worker directly without going through the network
  • Declare App.Platform in dashboard/src/app.d.ts to type the binding
  • Both +page.server.ts load functions now use platform?.env?.WORKER?.fetch when available, falling back to SvelteKit fetch for local dev

Test plan

  • Deploy Pages project — binding should resolve automatically from the updated wrangler.jsonc
  • Visit coverage-tracker.zerostash.org — dashboard should load without 500
  • Visit a repo detail page (/owner/repo) — trend data should load correctly
  • Confirm local dev still works (npm run dev in dashboard/) — falls back to URL-based fetch

🤖 Generated with Claude Code

Pages server-side fetch calls to the same hostname bypass Worker route
matching (same-zone fetch), causing /api/* requests to land on Pages
and return 404. Switch to a Cloudflare service binding so the Pages
function calls the Worker directly without going through the network.

- Add WORKER service binding in dashboard/wrangler.jsonc
- Declare App.Platform type in dashboard/src/app.d.ts
- Use binding fetch in both +page.server.ts load functions, falling
  back to the SvelteKit fetch for local dev

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tbjers
tbjers merged commit 315e3e1 into main Jun 24, 2026
4 checks passed
@tbjers
tbjers deleted the fix/dashboard-same-zone-fetch branch June 24, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant