swadhinbiswas

[email protected]
2026-09-12 23:50:37 +0600 committed NaN years ago
43467a2
commit 43467a2
3 files changed
+63 -0
Showing 3 changed files+63-0
▼README.md
+39-0
364
364
`VITE_LIVE_URL` (Settings → Secrets and variables → Actions → Variables) and
365
365
re-run the `Frontend` workflow.
366
366
367
+### Deploy the dashboard (Cloudflare Pages)
368
+
369
+`VITE_*` values are inlined by Vite, so **they must exist when the build runs** —
370
+setting them on Cloudflare only works if Cloudflare performs the build.
371
+
372
+**Git-connected project** (Cloudflare builds it) — Pages → project → Settings:
373
+
374
+| Setting | Value |
375
+|---|---|
376
+| Root directory | *(repo root)* |
377
+| Build command | `cd web && npm ci && npm run build` |
378
+| Build output directory | `web/dist` |
379
+
380
+Environment variables (Production **and** Preview), then **Retry deployment**:
381
+
382
+| Variable | Value |
383
+|---|---|
384
+| `VITE_LIVE_URL` | `https://vps.example.com` |
385
+| `VITE_TURSO_URL` | `libsql://<db>-<org>.turso.io` |
386
+| `VITE_TURSO_TOKEN` | a **read-only** Turso token (it is public in the bundle) |
387
+| `VITE_API_URL` | optional FastAPI warehouse API |
388
+
389
+**Direct upload** (no Cloudflare build) — cloud env vars do nothing; build first,
390
+then deploy. The `Frontend` workflow already has the secrets:
391
+
392
+```bash
393
+gh run download -n web-dashboard -D /tmp/web-dist
394
+npx wrangler pages deploy /tmp/web-dist # wrangler.toml names the project
395
+```
396
+
397
+Verify the variables are actually baked in:
398
+
399
+```bash
400
+curl -s https://<project>.pages.dev/ | grep -o '/assets/index-[^"]*\.js' | head -1
401
+curl -s "https://<project>.pages.dev/assets/index-XXXX.js" | grep -c "turso.io"
402
+```
403
+
404
+Non-zero means the bundle has the URL and the dashboard can reach Turso.
405
+
367
406
### Docker Compose
368
407
369
408
```bash
370
409
▼web/public/_headers
+9-0
1
+# Vite fingerprints every file under /assets, so they can be cached forever.
2
+/assets/*
3
+ Cache-Control: public, max-age=31536000, immutable
4
+
5
+# Always revalidate the entry document so a new deploy is picked up at once.
6
+/index.html
7
+ Cache-Control: public, max-age=0, must-revalidate
8
+/
9
+ Cache-Control: public, max-age=0, must-revalidate
0
10
▼wrangler.toml
+15-0
1
+# Cloudflare Pages project for the dashboard.
2
+#
3
+# Git-connected builds: set the build command in the Pages dashboard
4
+# Build command: cd web && npm ci && npm run build
5
+# Build output: web/dist (also declared below)
6
+# and add the build-time variables under Settings → Environment variables:
7
+# VITE_LIVE_URL https://vps.example.com (VPS live API)
8
+# VITE_TURSO_URL libsql://<db>-<org>.turso.io (same as TURSO_DATABASE_URL)
9
+# VITE_TURSO_TOKEN a READ-ONLY Turso token — it is inlined into the bundle
10
+# VITE_API_URL optional FastAPI warehouse API
11
+#
12
+# Manual deploys: npx wrangler pages deploy web/dist
13
+name = "airtraffic-eu"
14
+pages_build_output_dir = "web/dist"
15
+compatibility_date = "2024-08-01"
0
16