Skip to content

Commit dbb52f7

Browse files
tbjersclaude
andcommitted
Fix dashboard API redirect handling and scope wrangler config
- api.ts: add redirect:'manual' to all Worker fetch calls so that Cloudflare Access login redirects (302) surface as HTTP errors instead of silently returning HTML that breaks JSON.parse - Add dashboard/wrangler.toml so the adapter-cloudflare dev server stops walking up to the root wrangler.jsonc (which was injecting the Worker's WORKER_URL env var into the dashboard process) - Update .gitignore to cover .dev.vars; update .env.example to document both Vite (.env) and wrangler (.dev.vars) dev patterns Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b89e1f5 commit dbb52f7

4 files changed

Lines changed: 12 additions & 1 deletion

File tree

dashboard/.env.example

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
# Copy to .env for local development
1+
# For local development with `npm run dev` (Vite):
2+
# Copy to .env
3+
#
4+
# For local development with `wrangler pages dev` (simulates Cloudflare runtime):
5+
# Copy to .dev.vars
6+
27
WORKER_URL=https://coverage-tracker.yourdomain.com

dashboard/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ build/
44
.env
55
.env.*
66
!.env.example
7+
.dev.vars

dashboard/src/lib/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export async function fetchProjects(
77
): Promise<ProjectRow[]> {
88
const res = await fetchFn(`${workerUrl}/api/projects`, {
99
headers: { 'Cf-Access-Jwt-Assertion': jwt },
10+
redirect: 'manual',
1011
});
1112
if (!res.ok) throw new Error(`Failed to fetch projects: HTTP ${res.status}`);
1213
return res.json() as Promise<ProjectRow[]>;
@@ -28,6 +29,7 @@ export async function fetchTrend(
2829
url.searchParams.set('limit', String(limit));
2930
const res = await fetchFn(url.toString(), {
3031
headers: { 'Cf-Access-Jwt-Assertion': jwt },
32+
redirect: 'manual',
3133
});
3234
if (!res.ok) throw new Error(`Failed to fetch trend: HTTP ${res.status}`);
3335
return res.json() as Promise<TrendResponse>;

dashboard/wrangler.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name = "coverage-tracker-dashboard"
2+
compatibility_date = "2024-11-01"
3+
pages_build_output_dir = ".svelte-kit/cloudflare"

0 commit comments

Comments
 (0)