mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
create-pull-request/patch
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6236fa4ec5 |
chore: remove the Cloudflare R2 asset upload and asset CDN (#53148)
Removes the dead Cloudflare R2 asset upload and asset CDN code from Studio, docs and www. Every app now behaves as it did with `FORCE_ASSET_CDN=-1`: Vercel serves assets from the default path. Also fixes `.github/workflows/zizmor.yml` to download zizmor with `gh release download`: `curl -sSLO` saved GitHub error pages as the archive, which broke the attestation check. > [!WARNING] > Remove `FORCE_ASSET_CDN` from Vercel only after this deploys. **Worth a close look** - `apps/studio/vite.config.ts`: `SKIP_ASSET_UPLOAD` is kept because it still gates Sentry source map upload. - `apps/studio/turbo.jsonc`: `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` are kept because the Bedrock credential chain (`lib/ai/bedrock.ts`) can fall back to them. ## To test - [ ] On the Vercel previews for studio, docs and www, open a page with DevTools: JS, CSS and fonts load from the app's own origin (`/dashboard/assets/…` or `/dashboard/_vercel/immutable/…` for Studio, `/docs/_next/static/…` for docs, `/_next/static/…` for www), with no 404s or CSP errors in the console. --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com> |
||
|
|
3f59d25833 |
feat(studio): serve TanStack client assets from the asset CDN (#52397)
Studio's TanStack build serves every client JS/CSS chunk from Vercel at
`/dashboard/_vercel/immutable/...`, and each of those requests also goes
through the www zone's routing (supabase.com/dashboard is proxied by
www). The Next build served the same files from the R2 asset CDN. This
moves the TanStack build's client assets back to the asset CDN on
production builds, using native Vite / TanStack Start hooks rather than
an `assetPrefix`-style rewrite.
**Added:**
- `apps/studio/asset-cdn.ts`: one gate shared with `next.config.ts`
(production or `FORCE_ASSET_CDN=1`, `FORCE_ASSET_CDN=-1` disables,
staging CDN when `NEXT_PUBLIC_ENVIRONMENT=staging`) plus URL helpers.
Only files under `_vercel/immutable/` are rewritten, and web workers
never are
- `upload-static-assets.sh tanstack`: syncs
`.vercel/output/static/_vercel/immutable` to
`<SITE_NAME>/tanstack/_vercel/immutable` on R2 with `max-age=31536000,
immutable`. Uses `--size-only` (names are content hashes, so only new
files upload) and excludes source maps. Local files are kept
- The upload script now fails with a clear message when the asset CDN is
enabled but `ASSET_CDN_S3_ENDPOINT` or the AWS keys are missing, instead
of the AWS CLI failing on an empty `--endpoint-url`
- Unit tests for the gate and URL helpers
**Changed:**
- `server.ts` uses `createStartHandler({ transformAssets })` so the
shell's scripts, modulepreloads and stylesheets point at the CDN with
`crossorigin="anonymous"` (module scripts need CORS; it also keeps full
error details in Sentry)
- `vite.config.ts` sets `experimental.renderBuiltUrl` (client only) so
URLs inside the bundle follow: the preload helper's dependency map, and
fonts/images referenced from CSS. The CDN base is computed once from the
process env (the same env the upload script sees) and inlined into both
server and client so they can't disagree
- `build:tanstack` runs the upload after `vite build` unless
`SKIP_ASSET_UPLOAD=1`, the same as `build:next`. The Docker image's
TanStack build sets `SKIP_ASSET_UPLOAD=1` (images serve their own
assets, and the pruned context has no upload script)
**Unchanged on purpose:**
- Vite `base` and the router basepath stay `/dashboard`; documents,
`/_serverFn` and `/api` stay on Vercel
- Web workers stay same-origin (`worker-src 'self' blob: data:`, and
workers must be same-origin anyway), so `immutableStaticFiles` stays on
- With the CDN off (previews, self-hosted), the build output is
identical to master apart from release hashes
The CDN folder is shared and content-addressed rather than per-commit,
so unchanged chunks dedupe across deploys and older tabs keep finding
their lazy chunks whichever deployment serves the next document.
**Rollout:** production has `FORCE_ASSET_CDN=-1` for now, so merging
this doesn't change prod. Staging picks it up on merge and gets tested
first.
## To test
### On the preview (tests the upload, not the page)
The staging preview for this branch builds with `FORCE_ASSET_CDN=1`, so
it exercises the real build-and-upload path. **The preview page itself
is expected not to load in a browser:** the asset CDN only allows the
staging and production origins in its CORS rules, so module scripts are
blocked on a `*.vercel.app` URL.
- In the build log, check `Uploading immutable static files to R2...` is
followed by `Upload completed successfully!`
- View the preview's page source: the `<script>`, `modulepreload` and
stylesheet tags point at the staging asset CDN
(`.../<SITE_NAME>/tanstack/_vercel/immutable/...`) with
`crossorigin="anonymous"`
- Open a few of those asset URLs directly in a new tab (a JS chunk, a
CSS file, and a `.woff2` font from the CSS): each returns 200 with the
right content type
- Worker URLs inside the chunks still point at
`/dashboard/_vercel/immutable/.../*.worker-*.js` on the page's own
origin
### After merge, on the full staging environment
- Load the staging dashboard with DevTools open: every script,
modulepreload and stylesheet comes from the staging asset CDN with a
200, and there are no CORS or CSP errors in the console
- Fonts render (Inter, and the code fonts in the SQL editor)
- Sign in and click around: Table Editor, SQL Editor, GraphiQL, Logs.
Lazy routes load, and nothing comes from `/dashboard/_vercel/immutable`
except Monaco's workers
- SQL Editor and GraphiQL: Monaco works (syntax highlighting,
autocomplete), and its workers load same-origin
- Trigger an error and check the Sentry event has a readable stack trace
- After the next staging deploy, check the build log's upload only added
new files
---------
Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
|
||
|
|
f2876c7787 |
chore(studio): upgrade the TanStack dependency set (#51067)
TanStack Start 1.169 is the stable release. This moves the shared catalog to Start 1.169.2 and Router 1.170.44, the newest matching pair that clears the 72-hour release-age gate, and updates Studio React Query and its devtools to 5.104.3. The ui-library TanStack auth blocks switch to `.validator()` because Start 1.169 removes `.inputValidator()`. **Changed:** - `pnpm-workspace.yaml` – `@tanstack/react-router` `^1.170.44` and `@tanstack/react-start` `^1.169.2`, so Router, Start, router-core, and the Start plugin install as one set - `pnpm-lock.yaml` – react-router 1.170.44, react-start 1.169.2, router-core 1.171.37, router-plugin 1.168.46, start-plugin-core 1.171.53, history 1.162.5, and Studio React Query 5.104.3 - `apps/studio/package.json` – `@tanstack/react-query` and `@tanstack/react-query-devtools` `~5.104.3`, `@tanstack/react-router-devtools` `^1.167.2` - `apps/ui-library/registry/default/blocks/password-based-auth-tanstack/routes/auth/confirm.ts` – `createServerFn` uses `.validator()` - `apps/ui-library/registry/default/blocks/social-auth-tanstack/routes/auth/oauth.ts` – `createServerFn` uses `.validator()` - `apps/ui-library/tests/sign-up-redirect.test.tsx` – the server-function mock follows the `validator` chain - `apps/ui-library/public/r/password-based-auth-tanstack.json` – registry JSON regenerated from the block - `apps/ui-library/public/r/social-auth-tanstack.json` – registry JSON regenerated from the block - `apps/ui-library/content/docs/tanstack/password-based-auth.mdx` – note that the block requires `@tanstack/react-start` 1.168.25 or later, since `.validator()` is missing from earlier Start versions - `apps/ui-library/content/docs/tanstack/social-auth.mdx` – note that the block requires `@tanstack/react-start` 1.168.25 or later, since `.validator()` is missing from earlier Start versions - `apps/studio/server.ts` – correct the header comment: `wrapFetchWithSentry` only adds a span, trace meta tags, and a flush, and request errors are captured by the Sentry middleware in `start.ts` **Removed:** - `minimumReleaseAgeExclude` pins for: - `@tanstack/react-router@1.170.41` - `@tanstack/react-start-client@1.168.39` - `@tanstack/react-start-rsc@0.1.59` - `@tanstack/react-start-server@1.167.46` - `@tanstack/react-start@1.168.60` - `@tanstack/react-store@0.11.2` - `@tanstack/router-core@1.171.34` - `@tanstack/router-generator@1.167.40` - `@tanstack/router-plugin@1.168.42` - `@tanstack/start-client-core@1.170.34` - `@tanstack/start-plugin-core@1.171.49` - `@tanstack/start-server-core@1.169.39` - `@tanstack/start-storage-context@1.167.36` - `@tanstack/store@0.11.2` ## To test - TanStack Studio, open a project home – the shell loads with no router error - TanStack Studio, open a table, switch schema, then Back and Forward – the table id follows history, and Forward returns to the later table - TanStack Studio, run a query in the SQL Editor – results render - TanStack Studio, open Project Settings – the general settings page renders - Next Studio, repeat home, Table Editor, SQL Editor, and Settings – the same pages render - ui-library TanStack password and social auth blocks, follow a sign-up confirm and OAuth confirm link – the server function accepts the search params through `.validator()` and redirects --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> |
||
|
|
3bac7165bd |
chore(studio): move the TanStack Start deploy onto Nitro (#50030)
Moves the Studio TanStack Start build off the hand-rolled Vercel setup (an `api/server.js` function shim, rewrites in `vercel.ts`, a custom `?dpl=` skew-protection Vite plugin, and `scripts/serve.js` for self-hosted) and onto Nitro, which TanStack Start documents as its deployment path. Documents are served from the static SPA shell on the CDN; only `/api/*` and `/_serverFn/*` invoke the function. **Removed:** - `api/server.js`, `scripts/serve.js`, `scripts/smoke-server.mjs` - The `skewProtectionDpl` Vite plugin, `renderBuiltUrl`, and the `vite:preloadError` reload backstop in `router.tsx` (TanStack Router already reloads once on a failed lazy import) - Rewrites, `functions`, `outputDirectory`, and `cleanUrls` from `vercel.ts` (redirects and headers stay) - `magic-string` and `@jridgewell/remapping` devDependencies, the `preview` script **Added:** - `nitro` plugin in `vite.config.ts`. Preset is auto-detected: `.vercel/output` on Vercel, a self-contained node server in `.output` everywhere else. `vercel.immutableStaticFiles` puts hashed chunks under `/_vercel/immutable/` so tabs opened before a redeploy keep loading their chunks; `functions.maxDuration: 300` carries over the old function timeout - `scripts/vercel-spa-routes.ts`: Nitro module that rewrites the generated Build Output routes (documents -> `_shell.html`, allow-list -> `__server`, missing chunk -> 404, base-path prefixes), with a unit test - `server.ts`: TanStack Start server entry that initializes Sentry before the route tree loads and wraps the handler with `wrapFetchWithSentry` **Changed:** - `start:tanstack` runs `.output/server/index.mjs` directly with Node's `--env-file-if-exists` for the `.env` cascade. Node doesn't expand `$VAR` references, so `scripts/generateLocalEnv.js` now writes literal values into `.env.test` - Dockerfile's TanStack stage copies `.output` instead of running `pnpm deploy`; the `server.js` shim loads `.env` and imports the Nitro server - `NEXT_PUBLIC_BASE_PATH` (the platform's `/dashboard`) only sets the router basepath; Vite's `base` stays at the root so chunks can use the immutable store. The routes module emits prefixed rules for `/dashboard/api/*` and `/dashboard/_serverFn/*` and rewrites `public/` files requested under the prefix back to the root - Self-hosted security headers come from a Nitro `routeRules` entry; on Vercel they stay in `vercel.ts` - `tslib` is inlined for the build only: Nitro's dev runner has no interop for its CJS wrapper - Monaco's worker chunks follow the client assets dir so they land in the immutable store too Verified on the `studio-staging` preview (`STUDIO_FRAMEWORK=tanstack` is scoped to this branch there): documents come back as the static shell, `/dashboard/api/*` hits the function, `public/` files resolve under the prefix, a missing immutable chunk 404s. Across two deployments of this branch, the older deployment's chunks still load from the immutable store and requests carrying its `__vdpl` cookie are answered by that deployment. Self-hosted path covered by the TanStack E2E job and the Docker build job. ## To test - On the `studio-staging` preview: `/dashboard/project/<ref>` should show `content-disposition: inline; filename="_shell.html"` and a single-region `x-vercel-id`; `/dashboard/api/get-utc-time` a two-region id - Sign in and click through a few pages, including one that opens Monaco (SQL editor) so the worker chunks load - After the next deploy, a tab left open on the previous one should still navigate (lazy chunks) and call the API without errors - Self-hosted: `STUDIO_FRAMEWORK=tanstack pnpm --filter studio build && pnpm --filter studio start`, then check `/api/platform/profile` and that responses carry the security headers <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Production TanStack deployments now run on Nitro’s self-contained server output. * Vercel routing serves static pages first while directing API and server-function requests appropriately. * Server-function requests can include deployment identification for consistent handling. * Local environment generation now writes resolved configuration values. * **Bug Fixes** * Improved handling of missing static assets and SPA fallback routing. * Server-side error monitoring now captures request errors in the new runtime. * **Refactor** * Replaced the legacy production server and smoke-test workflow with Nitro-based startup. * Removed automatic reload handling for stale client assets. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com> |