Files
Dylan M. Taylor 766ead6629 Configure artcraft-dashboard for Cloudflare at dashboard.artcraft.team (#408)
## Problem

The admin dashboard is deployed only to Netlify
(`artcraft-dashboard.netlify.app`), while the rest of the frontends
deploy to Cloudflare from this repository. Move it to Cloudflare and
serve it at `dashboard.artcraft.team`.

## Change

- **`frontend/apps/artcraft-dashboard/wrangler.jsonc`** —
`artcraft-dashboard` static-assets Worker: SPA `not_found_handling`,
`run_worker_first: ["/api/*"]`, custom domain `dashboard.artcraft.team`.
- **`cloudflare_worker/index.ts`** — same-origin `/api/*` proxy to
`https://api.storyteller.ai`. The dashboard calls the API with
`credentials: "include"`, so its session cookie has to stay first-party;
`api.storyteller.ai` is a different site than `dashboard.artcraft.team`,
so a direct cross-site call would have the cookie dropped by browsers.
This replaces Netlify's `/api/*` rewrite.
- **`script/website/cloudflare_app.sh` + root `package.json`** —
`ARTCRAFT_APP=artcraft-dashboard`, plus `npm run build:dashboard` / `npm
run deploy:dashboard`.
- **`_redirects`** moved from `public/` to the app root and copied into
`dist/` by `netlify_build.sh`, so the Cloudflare upload never contains
the `/* /index.html 200` loop or the external-host proxy that Workers
reject. Netlify keeps working unchanged as the rollback target.
- **CORS** — `https://dashboard.artcraft.team` allowlisted in
`artcraft_admin_dashboard.rs`, the regression table, and the production
product-origin test.
- **`tsconfig.app.json`** — excludes spec files. `DebugLogCard.spec.ts`
imports `vitest`, which only resolved through the parent workspace's
`node_modules`; the standalone Cloudflare build never installs those, so
`tsc -b` failed.
- Docs: dashboard README (deploy, proxy rationale, rollback) and the
root README Worker table.

## Cloudflare settings

| Setting        | Value                             |
|----------------|-----------------------------------|
| Build command  | `npm run build`                   |
| Deploy command | `npm run deploy`                  |
| Build variable | `ARTCRAFT_APP=artcraft-dashboard` |
| Build variable | `NODE_VERSION=22`                 |

`VITE_API_HOST` is deliberately not set: the dashboard keeps calling
`/api`, and the Worker proxies it.

## Checklist before cutover

- [ ] `artcraft.team` is a zone in the Cloudflare account (Workers
custom domains require the zone).
- [ ] `artcraft-dashboard` Worker created from this repo with the
settings above.
- [ ] Domain attached; log in and confirm the session works at
`https://dashboard.artcraft.team`. A `*.workers.dev` URL is not
CORS-allowlisted, so test through the domain (or add the test host to
the CORS config first).
- [ ] Netlify site kept for rollback; reverting is pointing the domain
back at it.

## Testing

- `cargo test -p actix_cors_configs` — 81 passed, including the new
`dashboard_domain` case and the allowlist regression table.
- `pnpm install --frozen-lockfile && pnpm build` in
`frontend/apps/artcraft-dashboard` — succeeds (9014 modules); `dist/`
has no `_redirects`.
- `wrangler deploy --dry-run --config
frontend/apps/artcraft-dashboard/wrangler.jsonc` — clean: 5 assets,
`env.ASSETS` binding, no config warnings.
- Not run: an actual deploy, since there are no Cloudflare credentials
or account access in this environment.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* The ArtCraft Admin Dashboard is now available at
`dashboard.artcraft.team`, with dashboard API requests routed through
the new deployment.
* The dashboard’s production origin is now allowed for cross-origin
requests.
* **Documentation**
* Added deployment and build guidance for the dashboard, including its
Cloudflare hosting and API routing details.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-17 23:51:08 -05:00
..
2026-05-08 12:49:15 -04:00
2026-09-12 12:23:46 -04:00