diff --git a/.agents/skills/ask-the-docs/SKILL.md b/.agents/skills/ask-the-docs/SKILL.md
index 044d978f9a7..85f94aaf6d2 100644
--- a/.agents/skills/ask-the-docs/SKILL.md
+++ b/.agents/skills/ask-the-docs/SKILL.md
@@ -57,7 +57,7 @@ than with prose. Default to including a **Mermaid diagram** in answers
about:
- The MDX runtime vs markdown-export pipeline split.
-- Build flow (Turbo task graph → `build` → R2 upload in `vercel.json` → Vercel).
+- Build flow (Turbo task graph → `build` → Vercel).
- LLM/agent consumption surface (`llms.txt`, negotiation, bulk exports).
- Federated docs fetch flow.
- CI / PR flow.
@@ -82,7 +82,7 @@ at hand — they cite each other where context matters.
| [`reference/docs-app-direction.md`](./reference/docs-app-direction.md) | Refactoring vision and working norms — what new work should align with. |
| [`reference/known-issues.md`](./reference/known-issues.md) | Living list of broken, fragile, or in-flux systems. Check before depending on anything (federated docs, search, Sentry, reference-page architecture). |
| [`reference/app-map.md`](./reference/app-map.md) | Architecture cheat sheet — directories, the two-pipeline (MDX runtime + markdown export) model, heading/typography contract, telemetry, lint entries. |
-| [`reference/build-pipeline.md`](./reference/build-pipeline.md) | Turborepo task graph for building `apps/docs` — codegen, markdown generation, sitemap, R2 upload, Vercel deploy. Mermaid diagram included. |
+| [`reference/build-pipeline.md`](./reference/build-pipeline.md) | Turborepo task graph for building `apps/docs` — codegen, markdown generation, sitemap, Vercel deploy. Mermaid diagram included. |
| [`reference/llm-agent-surface.md`](./reference/llm-agent-surface.md) | Audience routing, `llms.txt`, content negotiation, bulk exports. |
| [`reference/llm-agent-parity.md`](./reference/llm-agent-parity.md) | HTML↔markdown fidelity (e.g. AI prompts), search caveat, agent onboarding guides, in-flux wiring. |
| [`reference/federated-docs.md`](./reference/federated-docs.md) | How docs pulls markdown from external repos at build time. Routes, `pageMap`, remark/rehype plugins, link transforms, known failure modes. |
diff --git a/.agents/skills/ask-the-docs/reference/build-pipeline.md b/.agents/skills/ask-the-docs/reference/build-pipeline.md
index 73e36dba88f..ec6b2041913 100644
--- a/.agents/skills/ask-the-docs/reference/build-pipeline.md
+++ b/.agents/skills/ask-the-docs/reference/build-pipeline.md
@@ -30,8 +30,6 @@ flowchart TB
SM --> DOC
RD --> DOC
end
-
- DOC --> CDN["upload-static-assets.sh
(R2, production-style deploys)
run by vercel.json buildCommand"]
```
## Commands
@@ -98,10 +96,6 @@ pipeline was defined twice and could drift. Add new steps to `turbo.jsonc`
only. See `packages/maybe-turbo/README.md` for why scripts use the wrapper
instead of calling `turbo` directly.
-The R2 asset upload used to be `postbuild`. It now runs from the
-`buildCommand` in `apps/docs/vercel.json`:
-`pnpm build && ./../../scripts/upload-static-assets.sh`.
-
## Codegen scripts
- **`codegen:graphql`** — generates GraphQL types from schema.
@@ -130,8 +124,7 @@ For how agents consume these outputs, see
## Deploy vs CI
- **Production build** for the site is **Vercel**; `apps/docs/vercel.json`
- sets `buildCommand` to `pnpm build && ./../../scripts/upload-static-assets.sh`
- (the Turbo graph above, then the R2 CDN upload on production-style deploys).
+ sets `buildCommand` to `pnpm build` (the Turbo graph above).
- **GitHub Actions** mostly run **tests** (`test:docs` → Turbo), **lint**,
**sync** jobs, and **smoke** tests — not a separate full production build
graph in the way Turbo does locally. See [`ci-and-lint.md`](./ci-and-lint.md).
diff --git a/.github/workflows/www-tests.yml b/.github/workflows/www-tests.yml
index c54fb5bdce8..adaf0dcc790 100644
--- a/.github/workflows/www-tests.yml
+++ b/.github/workflows/www-tests.yml
@@ -8,7 +8,6 @@ on:
- 'apps/www/**/*.ts*'
- 'apps/www/package.json'
- 'apps/www/turbo.jsonc'
- - 'scripts/upload-static-assets.sh'
- 'packages/common/sentry.ts'
- 'packages/common/sentry.test.ts'
- 'apps/www/next.config.mjs'
diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml
index 328eade145b..0e679b158bb 100644
--- a/.github/workflows/zizmor.yml
+++ b/.github/workflows/zizmor.yml
@@ -46,7 +46,7 @@ jobs:
run: |
set -euo pipefail
archive="zizmor-x86_64-unknown-linux-gnu.tar.gz"
- curl -sSLO "https://github.com/zizmorcore/zizmor/releases/download/v${ZIZMOR_VERSION}/${archive}"
+ gh release download "v${ZIZMOR_VERSION}" --repo zizmorcore/zizmor --pattern "${archive}"
gh attestation verify "${archive}" --repo zizmorcore/zizmor
mkdir -p ~/.local/bin
tar -xzf "${archive}" -C ~/.local/bin zizmor
diff --git a/apps/docs/next.config.mjs b/apps/docs/next.config.mjs
index 67dbe5707b2..26681b7274e 100644
--- a/apps/docs/next.config.mjs
+++ b/apps/docs/next.config.mjs
@@ -25,7 +25,6 @@ const withMDX = nextMdx({
/** @type {import('next').NextConfig} nextConfig */
const nextConfig = {
- assetPrefix: getAssetPrefix(),
// Append the default value with md extensions
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
// reactStrictMode: true,
@@ -188,18 +187,3 @@ export default withSentryConfig(configExport, {
// side errors will fail.
// tunnelRoute: "/monitoring",
})
-
-function getAssetPrefix() {
- // If not force enabled, but not production env, disable CDN
- if (process.env.FORCE_ASSET_CDN !== '1' && process.env.VERCEL_ENV !== 'production') {
- return undefined
- }
-
- // Force disable CDN
- if (process.env.FORCE_ASSET_CDN === '-1') {
- return undefined
- }
-
- // @ts-ignore
- return `https://frontend-assets.supabase.com/${process.env.SITE_NAME}/${process.env.VERCEL_GIT_COMMIT_SHA.substring(0, 12)}`
-}
diff --git a/apps/docs/turbo.jsonc b/apps/docs/turbo.jsonc
index 582a71ee3e4..8d1c1cb3879 100644
--- a/apps/docs/turbo.jsonc
+++ b/apps/docs/turbo.jsonc
@@ -194,9 +194,6 @@
"NEXT_PUBLIC_SUPABASE_ANON_KEY",
"NEXT_PUBLIC_MCP_URL",
// These envs are technically passthrough env vars because they're only used on the server side of Nextjs
- "ASSET_CDN_S3_ENDPOINT",
- "AWS_ACCESS_KEY_ID",
- "AWS_SECRET_ACCESS_KEY",
"CI",
"DOCS_GITHUB_APP_ID",
"DOCS_GITHUB_APP_INSTALLATION_ID",
@@ -207,11 +204,9 @@
"GH_TOKEN",
"GITHUB_ACTIONS",
"GITHUB_TOKEN",
- "FORCE_ASSET_CDN",
"LOGFLARE_INGESTION_API_KEY",
"LOGFLARE_SOURCE_TOKEN",
"OPENAI_API_KEY",
- "SITE_NAME",
"SUPABASE_SECRET_KEY",
],
"passThroughEnv": ["SENTRY_AUTH_TOKEN"],
diff --git a/apps/docs/vercel.json b/apps/docs/vercel.json
index 7dbbdc8b183..b99ddbe7107 100644
--- a/apps/docs/vercel.json
+++ b/apps/docs/vercel.json
@@ -1,4 +1,4 @@
{
- "buildCommand": "pnpm build && ./../../scripts/upload-static-assets.sh",
+ "buildCommand": "pnpm build",
"bulkRedirectsPath": "./lib/redirects/generated/static-redirects-md-variants.json"
}
diff --git a/apps/studio/Dockerfile b/apps/studio/Dockerfile
index 0411e0c0f7b..02f7f1ac96c 100644
--- a/apps/studio/Dockerfile
+++ b/apps/studio/Dockerfile
@@ -73,8 +73,7 @@ RUN mkdir -p /srv && \
# Compile TanStack Start (Vite + Nitro)
FROM dev AS build-tanstack
-# Images serve their own assets, and the pruned context has no upload script.
-RUN SKIP_ASSET_UPLOAD=1 NODE_OPTIONS=--max-old-space-size=4096 pnpm --filter studio run build:tanstack
+RUN NODE_OPTIONS=--max-old-space-size=4096 pnpm --filter studio run build:tanstack
# Assemble the runtime tree at /srv. Nitro's node-server output is
# self-contained (`.output/server` bundles the app with its traced
diff --git a/apps/studio/asset-cdn.test.ts b/apps/studio/asset-cdn.test.ts
deleted file mode 100644
index a76edd4c357..00000000000
--- a/apps/studio/asset-cdn.test.ts
+++ /dev/null
@@ -1,130 +0,0 @@
-import { describe, expect, it } from 'vitest'
-
-import {
- getAssetCdnOrigin,
- getCdnUrlForBuiltFile,
- getTanstackAssetCdnUrl,
- isWorkerAsset,
- toCdnAssetUrl,
-} from './asset-cdn'
-
-const CDN = 'https://frontend-assets.supabase.com/studio/tanstack'
-
-describe('getAssetCdnOrigin', () => {
- it('is disabled outside production', () => {
- expect(getAssetCdnOrigin({})).toBeUndefined()
- expect(getAssetCdnOrigin({ VERCEL_ENV: 'preview' })).toBeUndefined()
- })
-
- it('is enabled on production deployments', () => {
- expect(getAssetCdnOrigin({ VERCEL_ENV: 'production' })).toBe(
- 'https://frontend-assets.supabase.com'
- )
- })
-
- it('can be force enabled', () => {
- expect(getAssetCdnOrigin({ FORCE_ASSET_CDN: '1' })).toBe('https://frontend-assets.supabase.com')
- })
-
- it('force disabling wins over a production deployment', () => {
- expect(getAssetCdnOrigin({ FORCE_ASSET_CDN: '-1', VERCEL_ENV: 'production' })).toBeUndefined()
- })
-
- it('uses the staging CDN on staging', () => {
- expect(
- getAssetCdnOrigin({ VERCEL_ENV: 'production', NEXT_PUBLIC_ENVIRONMENT: 'staging' })
- ).toBe('https://frontend-assets.supabase.green')
- })
-})
-
-describe('getTanstackAssetCdnUrl', () => {
- it('uses a shared folder under the site name', () => {
- expect(getTanstackAssetCdnUrl({ VERCEL_ENV: 'production', SITE_NAME: 'supabase-studio' })).toBe(
- 'https://frontend-assets.supabase.com/supabase-studio/tanstack'
- )
- })
-
- it('defaults the site name to studio', () => {
- expect(getTanstackAssetCdnUrl({ VERCEL_ENV: 'production' })).toBe(CDN)
- })
-
- it('is undefined when the CDN is disabled', () => {
- expect(getTanstackAssetCdnUrl({ SITE_NAME: 'studio' })).toBeUndefined()
- })
-})
-
-describe('isWorkerAsset', () => {
- it('matches Vite worker output', () => {
- expect(isWorkerAsset('_vercel/immutable/initial/nitro/json.worker-BXx3_a-9.js')).toBe(true)
- expect(isWorkerAsset('_vercel/immutable/initial/nitro/editor.worker-Ab12Cd34.js')).toBe(true)
- })
-
- it('does not match regular chunks', () => {
- expect(isWorkerAsset('_vercel/immutable/initial/nitro/index-BKEvKWTwe3h6KAdk.js')).toBe(false)
- expect(isWorkerAsset('_vercel/immutable/initial/nitro/worker-utils-Ab12Cd34.js')).toBe(false)
- })
-})
-
-describe('getCdnUrlForBuiltFile', () => {
- it('points immutable assets at the CDN', () => {
- expect(getCdnUrlForBuiltFile('_vercel/immutable/initial/nitro/index-abc123.js', CDN)).toBe(
- `${CDN}/_vercel/immutable/initial/nitro/index-abc123.js`
- )
- expect(getCdnUrlForBuiltFile('_vercel/immutable/initial/nitro/font-abc123.woff2', CDN)).toBe(
- `${CDN}/_vercel/immutable/initial/nitro/font-abc123.woff2`
- )
- })
-
- it('keeps workers on the host', () => {
- expect(
- getCdnUrlForBuiltFile('_vercel/immutable/initial/nitro/json.worker-abc123.js', CDN)
- ).toBeUndefined()
- })
-
- it('keeps files outside the immutable store on the host', () => {
- expect(getCdnUrlForBuiltFile('assets/index-abc123.js', CDN)).toBeUndefined()
- })
-
- it('is undefined when the CDN is disabled', () => {
- expect(
- getCdnUrlForBuiltFile('_vercel/immutable/initial/nitro/index-abc123.js', undefined)
- ).toBeUndefined()
- })
-})
-
-describe('toCdnAssetUrl', () => {
- it('strips the base path from manifest URLs', () => {
- expect(
- toCdnAssetUrl('/dashboard/_vercel/immutable/initial/nitro/index-abc.js', CDN, '/dashboard')
- ).toBe(`${CDN}/_vercel/immutable/initial/nitro/index-abc.js`)
- })
-
- it('works without a base path', () => {
- expect(toCdnAssetUrl('/_vercel/immutable/initial/nitro/index-abc.js', CDN)).toBe(
- `${CDN}/_vercel/immutable/initial/nitro/index-abc.js`
- )
- })
-
- it('leaves other URLs unchanged', () => {
- expect(toCdnAssetUrl('/dashboard/favicon/favicon.ico', CDN, '/dashboard')).toBe(
- '/dashboard/favicon/favicon.ico'
- )
- expect(toCdnAssetUrl('/other/_vercel/immutable/x.js', CDN, '/dashboard')).toBe(
- '/other/_vercel/immutable/x.js'
- )
- expect(
- toCdnAssetUrl(
- '/dashboard/_vercel/immutable/initial/nitro/json.worker-abc.js',
- CDN,
- '/dashboard'
- )
- ).toBe('/dashboard/_vercel/immutable/initial/nitro/json.worker-abc.js')
- expect(
- toCdnAssetUrl(
- '/dashboard/_vercel/immutable/initial/nitro/index-abc.js',
- undefined,
- '/dashboard'
- )
- ).toBe('/dashboard/_vercel/immutable/initial/nitro/index-abc.js')
- })
-})
diff --git a/apps/studio/asset-cdn.ts b/apps/studio/asset-cdn.ts
deleted file mode 100644
index 5f17d875947..00000000000
--- a/apps/studio/asset-cdn.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-type Env = Record
-
-/**
- * Origin of the Cloudflare R2 asset CDN, or `undefined` when assets are served
- * by the host. Enabled on production deployments or with `FORCE_ASSET_CDN=1`;
- * `FORCE_ASSET_CDN=-1` (e.g. self-hosted) always disables it.
- */
-export function getAssetCdnOrigin(env: Env = process.env): string | undefined {
- if (env.FORCE_ASSET_CDN === '-1') return undefined
- if (env.FORCE_ASSET_CDN !== '1' && env.VERCEL_ENV !== 'production') return undefined
-
- return env.NEXT_PUBLIC_ENVIRONMENT === 'staging'
- ? 'https://frontend-assets.supabase.green'
- : 'https://frontend-assets.supabase.com'
-}
-
-/**
- * CDN base for the TanStack build's client assets. The folder is shared by
- * every deployment rather than keyed by commit: the files under it are
- * content-hashed, so identical chunks dedupe across deploys, and a tab opened
- * on an older deployment keeps finding its lazy chunks no matter which
- * deployment serves the next document. Must match the destination in
- * `scripts/upload-static-assets.sh`.
- */
-export function getTanstackAssetCdnUrl(env: Env = process.env): string | undefined {
- const origin = getAssetCdnOrigin(env)
- if (!origin) return undefined
- return `${origin}/${env.SITE_NAME || 'studio'}/tanstack`
-}
-
-/**
- * Nitro's Vercel immutable store, the only directory uploaded to the CDN.
- * Anything outside it (public files, non-Vercel builds) stays on the host.
- */
-const IMMUTABLE_ASSETS_DIR = '_vercel/immutable/'
-
-/**
- * Web workers (Vite `?worker` output, e.g. graphiql's Monaco workers) must
- * stay same-origin: browsers refuse to construct a Worker from a cross-origin
- * script, and the CSP only allows `worker-src 'self' blob: data:`.
- */
-export function isWorkerAsset(filename: string): boolean {
- return /\.worker-[\w-]+\.js$/.test(filename)
-}
-
-/**
- * CDN URL for a built client file, given its path relative to the output root
- * (`_vercel/immutable//nitro/`), or `undefined` to keep the host URL.
- */
-export function getCdnUrlForBuiltFile(
- filename: string,
- cdnUrl: string | undefined
-): string | undefined {
- if (!cdnUrl || !filename.startsWith(IMMUTABLE_ASSETS_DIR) || isWorkerAsset(filename)) {
- return undefined
- }
- return `${cdnUrl}/${filename}`
-}
-
-/**
- * Rewrites an absolute asset URL from TanStack Start's manifest
- * (`${basePath}/_vercel/immutable/...`) to the CDN, returning it unchanged when
- * it isn't an uploaded asset.
- */
-export function toCdnAssetUrl(url: string, cdnUrl: string | undefined, basePath = ''): string {
- const prefix = `${basePath}/`
- if (!url.startsWith(prefix)) return url
- return getCdnUrlForBuiltFile(url.slice(prefix.length), cdnUrl) ?? url
-}
diff --git a/apps/studio/csp.ts b/apps/studio/csp.ts
index 65a4b24b3cc..c5522cc1ba0 100644
--- a/apps/studio/csp.ts
+++ b/apps/studio/csp.ts
@@ -70,10 +70,6 @@ const STAPE_URL = 'https://ss.supabase.com'
const VERCEL_LIVE_URL = 'https://vercel.live'
const SENTRY_URL =
'https://*.ingest.sentry.io https://*.ingest.us.sentry.io https://*.ingest.de.sentry.io'
-const SUPABASE_ASSETS_URL =
- process.env.NEXT_PUBLIC_ENVIRONMENT === 'staging'
- ? 'https://frontend-assets.supabase.green'
- : 'https://frontend-assets.supabase.com'
const POSTHOG_URL = isDevOrStaging ? 'https://ph.supabase.green' : 'https://ph.supabase.com'
const USERCENTRICS_URLS = 'https://*.usercentrics.eu'
@@ -103,7 +99,6 @@ export function getCSP() {
VERCEL_INSIGHTS_URL,
GITHUB_API_URL,
GITHUB_USER_CONTENT_URL,
- SUPABASE_ASSETS_URL,
USERCENTRICS_URLS,
STAPE_URL,
GOOGLE_MAPS_API_URL,
@@ -115,7 +110,6 @@ export function getCSP() {
CLOUDFLARE_CDN_URL,
HCAPTCHA_JS_URL,
STRIPE_JS_URL,
- SUPABASE_ASSETS_URL,
STAPE_URL,
POSTHOG_URL,
USERCENTRICS_URLS,
@@ -140,15 +134,14 @@ export function getCSP() {
GOOGLE_USER_AVATAR_URL,
// Vercel integration account avatars (https://vercel.com/api/www/avatar/...)
VERCEL_URL,
- SUPABASE_ASSETS_URL,
USERCENTRICS_APP_URL,
STAPE_URL,
USERCENTRICS_URLS,
MARKETPLACE_API_URL,
...(!!NIMBUS_PROD_PROJECTS_URL ? [NIMBUS_PROD_PROJECTS_URL, NIMBUS_PROD_PROJECTS_URL_WS] : []),
]
- const STYLE_SRC_URLS = [CLOUDFLARE_CDN_URL, SUPABASE_ASSETS_URL]
- const FONT_SRC_URLS = [CLOUDFLARE_CDN_URL, SUPABASE_ASSETS_URL]
+ const STYLE_SRC_URLS = [CLOUDFLARE_CDN_URL]
+ const FONT_SRC_URLS = [CLOUDFLARE_CDN_URL]
const defaultSrcDirective = [
`default-src 'self'`,
diff --git a/apps/studio/next.config.ts b/apps/studio/next.config.ts
index 907929a8efe..f13b041acd0 100644
--- a/apps/studio/next.config.ts
+++ b/apps/studio/next.config.ts
@@ -4,7 +4,6 @@ import bundleAnalyzer from '@next/bundle-analyzer'
import { withSentryConfig } from '@sentry/nextjs'
import type { NextConfig } from 'next'
-import { getAssetCdnOrigin } from './asset-cdn'
import { getCSP } from './csp'
import {
getMaintenanceRedirects,
@@ -17,13 +16,6 @@ const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
})
-function getAssetPrefix() {
- const assetCdnOrigin = getAssetCdnOrigin()
- if (!assetCdnOrigin) return undefined
-
- return `${assetCdnOrigin}/${process.env.SITE_NAME}/${process.env.VERCEL_GIT_COMMIT_SHA?.substring(0, 12) ?? 'unknown'}`
-}
-
const isPlatform = process.env.NEXT_PUBLIC_IS_PLATFORM === 'true'
const marketplaceApiUrl = process.env.NEXT_PUBLIC_MARKETPLACE_API_URL
@@ -43,7 +35,6 @@ const marketplaceApiProtocol: 'http' | 'https' | null =
// types to a different major version than studio's own next dependency.
const nextConfig = {
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
- assetPrefix: getAssetPrefix(),
output: 'standalone',
experimental: {
clientRouterFilter: false,
diff --git a/apps/studio/package.json b/apps/studio/package.json
index a656d388117..320d6717e8e 100644
--- a/apps/studio/package.json
+++ b/apps/studio/package.json
@@ -10,10 +10,10 @@
"build": "node scripts/dispatch.js build",
"start": "node scripts/dispatch.js start",
"dev:next": "next dev -p ${STUDIO_PORT:-8082}",
- "build:next": "next build && if [ \"$SKIP_ASSET_UPLOAD\" != \"1\" ]; then ./../../scripts/upload-static-assets.sh; fi",
+ "build:next": "next build",
"start:next": "next start -p 8082",
"dev:tanstack": "NODE_OPTIONS=--max-old-space-size=8192 vite dev --port ${STUDIO_PORT:-8082}",
- "build:tanstack": "vite build --mode ${MODE:-production} && if [ \"$SKIP_ASSET_UPLOAD\" != \"1\" ]; then ./../../scripts/upload-static-assets.sh tanstack; fi",
+ "build:tanstack": "vite build --mode ${MODE:-production}",
"start:tanstack": "node --env-file-if-exists=.env --env-file-if-exists=.env.local --env-file-if-exists=.env.${MODE:-production} --env-file-if-exists=.env.${MODE:-production}.local .output/server/index.mjs",
"lint": "eslint . && pnpm run lint:type-checks",
"lint:type-checks": "eslint --no-inline-config --config eslint.type-checks.config.cjs .",
diff --git a/apps/studio/redirects.shared.ts b/apps/studio/redirects.shared.ts
index be9545d1bd9..9f9cfc75199 100644
--- a/apps/studio/redirects.shared.ts
+++ b/apps/studio/redirects.shared.ts
@@ -388,9 +388,9 @@ export const SHARED_REDIRECTS: StudioRedirect[] = [
// page doesn't depend on either.
export const MAINTENANCE_PASSTHROUGH_SEGMENTS = [
'maintenance',
- // Build output. Next chunks (`/_next`, which Next also never redirects
- // itself) are served from the app when no asset CDN is configured. Vite's
- // chunks are under `/assets`, or `/_vercel/immutable//nitro` on Vercel.
+ // Build output. Next chunks are under `/_next` (which Next also never
+ // redirects itself). Vite's chunks are under `/assets`, or
+ // `/_vercel/immutable//nitro` on Vercel.
'_next',
'_vercel',
'assets',
diff --git a/apps/studio/server.ts b/apps/studio/server.ts
index 6318b63aa89..2f4ad344ec5 100644
--- a/apps/studio/server.ts
+++ b/apps/studio/server.ts
@@ -3,34 +3,11 @@
import './instrument.server.mjs'
import { wrapFetchWithSentry } from '@sentry/tanstackstart-react'
-import { createStartHandler, defaultStreamHandler } from '@tanstack/react-start/server'
-import { createServerEntry, type ServerEntry } from '@tanstack/react-start/server-entry'
-
-import { toCdnAssetUrl } from './asset-cdn'
-
-// Inlined by vite.config.ts so the document (prerendered `_shell.html`) and the
-// client bundle's `renderBuiltUrl` always agree on the CDN base.
-declare const __STUDIO_ASSET_CDN_URL__: string | undefined
-
-const assetCdnUrl = __STUDIO_ASSET_CDN_URL__
-const basePath = process.env.NEXT_PUBLIC_BASE_PATH
-
-const handler = createStartHandler({
- handler: defaultStreamHandler,
- ...(assetCdnUrl && {
- transformAssets: ({ url, kind }) => {
- const href = toCdnAssetUrl(url, assetCdnUrl, basePath)
- // Cross-origin module scripts need CORS, and it also keeps error
- // details (not just "Script error.") visible to Sentry.
- if (href === url || kind === 'css-url') return { href }
- return { href, crossOrigin: 'anonymous' }
- },
- }),
-})
+import handler, { createServerEntry, type ServerEntry } from '@tanstack/react-start/server-entry'
const requestHandler: ServerEntry = wrapFetchWithSentry({
fetch(request: Request) {
- return handler(request)
+ return handler.fetch(request)
},
})
diff --git a/apps/studio/turbo.jsonc b/apps/studio/turbo.jsonc
index cb4c73574dc..54e61b5434b 100644
--- a/apps/studio/turbo.jsonc
+++ b/apps/studio/turbo.jsonc
@@ -93,9 +93,6 @@
"AWS_BEDROCK_ROLE_ARN",
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
- "FORCE_ASSET_CDN",
- "ASSET_CDN_S3_ENDPOINT",
- "SITE_NAME",
"VERCEL_URL",
"IS_BRAINTRUST_PUSH",
"GITHUB_HEAD_REF",
diff --git a/apps/studio/vite.config.ts b/apps/studio/vite.config.ts
index cf00aad2f2b..4b7723e2892 100644
--- a/apps/studio/vite.config.ts
+++ b/apps/studio/vite.config.ts
@@ -12,7 +12,6 @@ import viteReact from '@vitejs/plugin-react'
import { nitro } from 'nitro/vite'
import { defineConfig, loadEnv, type Plugin } from 'vite'
-import { getCdnUrlForBuiltFile, getTanstackAssetCdnUrl } from './asset-cdn'
import { PRERENDERED_ROUTES } from './lib/prerendered-routes'
import { vercelSpaRoutes } from './scripts/vercel-spa-routes'
import { getSecurityHeaders } from './security-headers'
@@ -559,14 +558,6 @@ export default defineConfig(({ command, mode }) => {
const basePath = env.NEXT_PUBLIC_BASE_PATH || undefined
// Self-hosted sign-in redirects straight to the default project, so there's nothing to prerender.
const prerenderedRoutes = env.NEXT_PUBLIC_IS_PLATFORM === 'true' ? PRERENDERED_ROUTES : []
- // Client JS/CSS (and CSS-referenced fonts/images) load from the R2 asset CDN
- // on production builds, uploaded by scripts/upload-static-assets.sh. Vite's
- // base stays `/dashboard` so documents, server functions and API routes stay
- // on Vercel. The shell's asset tags are rewritten by server.ts. Reads the
- // process env, not `env`: the upload script only sees the process env, so a
- // CDN switch set in a `.env*` file must not point the build at assets that
- // were never uploaded.
- const assetCdnUrl = command === 'build' ? getTanstackAssetCdnUrl(process.env) : undefined
const shouldUploadSourceMaps =
process.env.SKIP_ASSET_UPLOAD !== '1' && !!process.env.SENTRY_AUTH_TOKEN
@@ -661,19 +652,7 @@ export default defineConfig(({ command, mode }) => {
define: {
...publicEnvDefines,
...sharedDefines,
- __STUDIO_ASSET_CDN_URL__: JSON.stringify(assetCdnUrl) ?? 'undefined',
},
- ...(assetCdnUrl && {
- experimental: {
- // Absolute CDN URLs for client assets referenced from JS and CSS. With
- // this set, Vite's preload helper resolves a lazy chunk's deps against
- // the importing chunk's URL, so they follow it to the CDN.
- renderBuiltUrl(filename: string, { ssr }: { ssr: boolean }) {
- if (ssr) return
- return getCdnUrlForBuiltFile(filename, assetCdnUrl)
- },
- },
- }),
// Circular-dep workaround: pin shared library code into dedicated
// chunks so per-component chunks don't import from a chunk that
// (transitively) imports them back.
diff --git a/apps/www/README.md b/apps/www/README.md
index 6e3b34505d3..490c35f1a78 100644
--- a/apps/www/README.md
+++ b/apps/www/README.md
@@ -12,18 +12,15 @@ Run `pnpm build` from `apps/www`, or `pnpm build --filter=www` from the reposito
root. Vercel uses the app's `build` script by default.
`prebuild` refreshes remote content before Turbo hashes it. Turbo caches
-`build:next` (Next.js, sitemaps, and the customer RSS feed), then `postbuild`
-uploads assets even on cache hits. The outer `build` task stays uncached so
-neither preparation nor upload can be skipped. Uploads run after caching because
-the upload script removes `.next/static`.
+`build:next` (Next.js, sitemaps, and the customer RSS feed). The outer `build`
+task stays uncached so content preparation can't be skipped.
-Production cache reuse requires the same commit and inputs: CDN URLs include
-`VERCEL_GIT_COMMIT_SHA`. Set `FORCE_ASSET_CDN=-1` to disable local uploads.
-Running `build:next` directly skips content preparation and uploads.
+Production cache reuse requires the same commit and inputs, including
+`VERCEL_GIT_COMMIT_SHA`. Running `build:next` directly skips content preparation.
Run `pnpm exec vitest run turbo-build.test.ts` to check cache invalidation and
-asset restoration using real pnpm, Turbo, and the upload script with fixture
-generators, a stub compiler, and a fake AWS CLI.
+artifact restoration using real pnpm and Turbo with fixture generators and a
+stub compiler.
## Best practices
diff --git a/apps/www/next.config.mjs b/apps/www/next.config.mjs
index 2687c451c9a..20d9f892329 100644
--- a/apps/www/next.config.mjs
+++ b/apps/www/next.config.mjs
@@ -39,7 +39,6 @@ const withBundleAnalyzer = bundleAnalyzer({
*/
const nextConfig = {
basePath: '',
- assetPrefix: getAssetPrefix(),
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],
trailingSlash: false,
transpilePackages: [
@@ -272,17 +271,3 @@ export default withSentryConfig(configExport, {
// side errors will fail.
// tunnelRoute: "/monitoring",
})
-
-function getAssetPrefix() {
- // If not force enabled, but not production env, disable CDN
- if (process.env.FORCE_ASSET_CDN !== '1' && process.env.VERCEL_ENV !== 'production') {
- return undefined
- }
-
- // Force disable CDN
- if (process.env.FORCE_ASSET_CDN === '-1') {
- return undefined
- }
-
- return `https://frontend-assets.supabase.com/${process.env.SITE_NAME}/${process.env.VERCEL_GIT_COMMIT_SHA.substring(0, 12)}`
-}
diff --git a/apps/www/package.json b/apps/www/package.json
index a325030266d..4815dc2a7f4 100644
--- a/apps/www/package.json
+++ b/apps/www/package.json
@@ -21,8 +21,7 @@
"sync:partner-form": "node scripts/syncPartnerIntakeForm.mjs",
"test": "vitest --run",
"test:watch": "vitest watch",
- "test:partner-form-sync": "vitest run --config vitest.sync.config.ts",
- "postbuild": "./../../scripts/upload-static-assets.sh"
+ "test:partner-form-sync": "vitest run --config vitest.sync.config.ts"
},
"dependencies": {
"@bsmnt/scrollytelling": "^0.3.3",
diff --git a/apps/www/turbo-build.test.ts b/apps/www/turbo-build.test.ts
index fc24530fc51..69b4c9c1792 100644
--- a/apps/www/turbo-build.test.ts
+++ b/apps/www/turbo-build.test.ts
@@ -45,8 +45,8 @@ const write = (file, value) => {
const event = (value) => fs.appendFileSync(path.join(root, '.checks/events'), value + '\\n');
`
-// Run the real pnpm lifecycle, Turbo binary/config, and uploader. Only remote
-// generators, Next compilation, and the aws executable are fixture stand-ins.
+// Run the real pnpm lifecycle and Turbo binary/config. Only remote generators
+// and Next compilation are fixture stand-ins.
json('package.json', { name: 'fixture', private: true, packageManager: 'pnpm@11.13.1' })
write('pnpm-workspace.yaml', 'packages:\n - apps/*\n - packages/*\n')
write(
@@ -142,22 +142,19 @@ write('.next/cache/temporary', 'not a deploy artifact');
write('public/customers-rss.xml', content);
`
)
-executable(
- 'node_modules/.bin/aws',
- helpers +
- `
-event('upload:' + process.argv[4]);
-if (!fs.existsSync('.next/static/chunk.js')) throw new Error('Upload is missing restored static assets');
-for (const file of ['public/rss.xml', 'public/customers-rss.xml', 'public/sitemap.xml', 'public/sitemap_www.xml', 'public/.well-known/agent-skills/index.json', '../docs/public/markdown/guides/example.md']) {
- if (!fs.existsSync(file)) throw new Error('Missing deployment artifact: ' + file);
+const deploymentArtifacts = [
+ 'apps/www/.next/static/chunk.js',
+ 'apps/www/public/rss.xml',
+ 'apps/www/public/customers-rss.xml',
+ 'apps/www/public/sitemap.xml',
+ 'apps/www/public/sitemap_www.xml',
+ 'apps/www/public/.well-known/agent-skills/index.json',
+ 'apps/docs/public/markdown/guides/example.md',
+]
+
+function missingArtifacts() {
+ return deploymentArtifacts.filter((file) => !fs.existsSync(path.join(fixture, file)))
}
-`
-)
-write(
- 'scripts/upload-static-assets.sh',
- fs.readFileSync(path.join(repoRoot, 'scripts/upload-static-assets.sh'), 'utf8')
-)
-fs.chmodSync(path.join(fixture, 'scripts/upload-static-assets.sh'), 0o755)
fs.symlinkSync(
path.join(repoRoot, 'node_modules/.bin/turbo'),
path.join(fixture, 'node_modules/.bin/turbo')
@@ -176,13 +173,7 @@ function build(env: Partial = {}, rootCommand = false) {
env: {
...process.env,
CI: 'true',
- FORCE_ASSET_CDN: '1',
- VERCEL_ENV: 'preview',
VERCEL_GIT_COMMIT_SHA: '1111111111111111111111111111111111111111',
- SITE_NAME: 'www',
- ASSET_CDN_S3_ENDPOINT: 'https://example.invalid',
- AWS_ACCESS_KEY_ID: 'test-access-key-id',
- AWS_SECRET_ACCESS_KEY: 'test-secret-access-key',
PATH: `${path.join(fixture, 'node_modules/.bin')}${path.delimiter}${process.env.PATH}`,
...env,
},
@@ -194,22 +185,14 @@ function build(env: Partial = {}, rootCommand = false) {
afterAll(() => fs.rmSync(fixture, { recursive: true, force: true }))
describe('www deployment build lifecycle', () => {
- it('builds fresh artifacts before uploading them', () => {
+ it('prepares content before compiling', () => {
const result = build()
expect(result.status, result.output).toBe(0)
- expect(events()).toEqual([
- 'docs:fetch',
- 'docs:markdown',
- 'www:content',
- 'compile',
- 'sitemap',
- 'upload:.next/static',
- 'upload:public',
- ])
- expect(fs.existsSync(path.join(app, '.next/static/chunk.js'))).toBe(false)
+ expect(events()).toEqual(['docs:fetch', 'docs:markdown', 'www:content', 'compile', 'sitemap'])
+ expect(missingArtifacts()).toEqual([])
}, 90_000)
- it('restores compiled assets and sitemaps and still uploads on a cache hit', () => {
+ it('restores compiled assets and sitemaps on a cache hit', () => {
fs.rmSync(path.join(app, '.next'), { recursive: true, force: true })
fs.rmSync(path.join(app, 'public'), { recursive: true, force: true })
const result = build()
@@ -217,7 +200,7 @@ describe('www deployment build lifecycle', () => {
expect(result.output).toContain('cache hit')
expect(events().filter((event) => event === 'compile')).toHaveLength(1)
expect(events().filter((event) => event === 'docs:fetch')).toHaveLength(2)
- expect(events().filter((event) => event.startsWith('upload:'))).toHaveLength(4)
+ expect(missingArtifacts()).toEqual([])
expect(fs.existsSync(path.join(app, '.next/cache/temporary'))).toBe(false)
}, 90_000)
@@ -262,27 +245,19 @@ describe('www deployment build lifecycle', () => {
expect(events().filter((event) => event === 'compile')).toHaveLength(count + 1)
}, 90_000)
- it('also refreshes content and uploads through the root Turbo build', () => {
+ it('also refreshes content through the root Turbo build', () => {
const count = events().filter((event) => event === 'compile').length
const result = build({}, true)
expect(result.status, result.output).toBe(0)
expect(events().filter((event) => event === 'compile')).toHaveLength(count)
- expect(events().slice(-5)).toEqual([
- 'docs:fetch',
- 'docs:markdown',
- 'www:content',
- 'upload:.next/static',
- 'upload:public',
- ])
+ expect(events().slice(-3)).toEqual(['docs:fetch', 'docs:markdown', 'www:content'])
}, 90_000)
it.each([{ FIXTURE_FAIL_PREPARE: '1' }, { NEXT_PUBLIC_FIXTURE_FAIL_BUILD: '1' }])(
- 'does not upload after an earlier build stage fails: %j',
+ 'fails the build when an earlier stage fails: %j',
(env) => {
- const uploads = events().filter((event) => event.startsWith('upload:')).length
const result = build(env)
expect(result.status, result.output).not.toBe(0)
- expect(events().filter((event) => event.startsWith('upload:'))).toHaveLength(uploads)
},
90_000
)
diff --git a/apps/www/turbo.jsonc b/apps/www/turbo.jsonc
index ee5c9554662..1a651b3bc95 100644
--- a/apps/www/turbo.jsonc
+++ b/apps/www/turbo.jsonc
@@ -10,7 +10,6 @@
},
"build": {
// pnpm's prebuild refreshes remote content before the nested build:next run hashes it.
- // postbuild uploads assets on every deployment, including build:next cache hits.
"cache": false,
"dependsOn": [],
"outputs": [],
@@ -59,8 +58,6 @@
"NOTION_FORMS_API_KEY",
"OPENAI_API_KEY",
"EMAIL_REPORT_SLACK_WEBHOOK",
- "FORCE_ASSET_CDN",
- "SITE_NAME",
"LUMA_API_KEY",
"LUMA_HACKATHONS_API_KEY",
"NEXT_RUNTIME",
diff --git a/scripts/upload-static-assets.sh b/scripts/upload-static-assets.sh
deleted file mode 100755
index 0f58c1f51ac..00000000000
--- a/scripts/upload-static-assets.sh
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/bin/bash
-set -eo pipefail
-
-#######
-
-# This script is used to upload static build assets (JS, CSS, ...) and public static files (public folder) to a CDN.
-# We're using Cloudflare R2 as CDN.
-# By using a CDN, we can serve static assets extremely fast while saving big time on egress costs.
-# An alternative is proxying via CF, but that comes with Orange-To-Orange issues (Cloudflare having issues with Cloudflare) and increased latency as there is a double TLS termination.
-# The script is only supposed to run on production deployments and is not run on any previews.
-
-# By using a dynamic path including the env, app and commit hash, we can ensure that there are no conflicts.
-# Static assets from previous deployments stick around for a while to ensure there are no "downtimes".
-
-# Advantages of the CDN approach we're using:
-
-# Get rid of egress costs for static assets across our apps on Vercel
-# Disable CF proxying and get around these odd timeouts issues
-# Save ~20ms or so for asset requests, as there is no additional CF proxying and we avoid terminating SSL twice
-# Always hits the CDN, gonna be super quick
-# Does not run on local or preview environments, only on staging/prod deployments
-# There are no other disadvantages - you don't have to consider it when developing locally, previews still work, everything on Vercel works as we're used to
-
-#######
-
-# If asset CDN is specifically disabled (i.e. studio self-hosted), we skip
-if [[ "$FORCE_ASSET_CDN" == "-1" ]]; then
- echo "Skipping asset upload. Set FORCE_ASSET_CDN=1 or VERCEL_ENV=production to execute."
- exit 0
-fi
-
-# Check for force env var or production environment
-if [[ "$FORCE_ASSET_CDN" != "1" ]] && [[ "$VERCEL_ENV" != "production" ]]; then
- echo "Skipping asset upload. Set FORCE_ASSET_CDN=1 or VERCEL_ENV=production to execute."
- exit 0
-fi
-
-# The build already points at the CDN at this point, so a missing credential
-# must fail the build rather than skip the upload.
-for var in ASSET_CDN_S3_ENDPOINT AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY; do
- if [[ -z "${!var}" ]]; then
- echo "Asset CDN upload is enabled but $var is not set. Set the R2 credentials for this environment, or FORCE_ASSET_CDN=-1 to disable the asset CDN."
- exit 1
- fi
-done
-
-# Set the cdnBucket variable based on NEXT_PUBLIC_ENVIRONMENT
-if [[ "$NEXT_PUBLIC_ENVIRONMENT" == "staging" ]]; then
- BUCKET_NAME="frontend-assets-staging"
-else
- BUCKET_NAME="frontend-assets-prod"
-fi
-
-STATIC_DIR=".next/static"
-PUBLIC_DIR="public"
-
-# Colors for output
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-NC='\033[0m' # No Color
-
-# Install AWS CLI if not present
-if ! command -v aws &> /dev/null; then
- echo -e "${YELLOW}Setting up AWS CLI...${NC}"
- curl -s "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.22.35.zip" -o "awscliv2.zip"
- unzip -q awscliv2.zip
- export PATH=$PWD/aws/dist:$PATH
- rm awscliv2.zip
-fi
-
-# TanStack Start builds (Studio): upload Nitro's Vercel immutable store, whose
-# files are content-hashed, to a folder shared by every deployment (see
-# apps/studio/asset-cdn.ts). Shared rather than per-commit so unchanged chunks
-# dedupe and older tabs keep resolving their lazy chunks. The files also stay in
-# the Vercel output: web workers must be served same-origin.
-if [[ "$1" == "tanstack" ]]; then
- IMMUTABLE_DIR=".vercel/output/static/_vercel/immutable"
- if [ ! -d "$IMMUTABLE_DIR" ]; then
- echo -e "${YELLOW}Directory $IMMUTABLE_DIR not found!${NC}"
- echo "Make sure the TanStack build ran for Vercel with immutable static files enabled."
- exit 1
- fi
-
- # Names are content hashes, so an existing object never needs replacing:
- # --size-only skips files a previous deployment already uploaded (the
- # default mtime check would re-upload every freshly built file). Source
- # maps are uploaded to Sentry, never published.
- echo -e "${YELLOW}Uploading immutable static files to R2...${NC}"
- aws s3 sync "$IMMUTABLE_DIR" "s3://$BUCKET_NAME/${SITE_NAME:-studio}/tanstack/_vercel/immutable" \
- --size-only \
- --exclude "*.map" \
- --endpoint-url "$ASSET_CDN_S3_ENDPOINT" \
- --cache-control "public,max-age=31536000,immutable" \
- --region auto \
- --only-show-errors
-
- echo -e "${GREEN}Upload completed successfully!${NC}"
- exit 0
-fi
-
-# Check if directory exists
-if [ ! -d "$STATIC_DIR" ]; then
- echo -e "${YELLOW}Directory $STATIC_DIR not found!${NC}"
- echo "Make sure you're running this script from your Next.js project root."
- exit 1
-fi
-
-# Upload files with cache configuration and custom endpoint
-echo -e "${YELLOW}Uploading static files to R2...${NC}"
-aws s3 sync "$STATIC_DIR" "s3://$BUCKET_NAME/$SITE_NAME/${VERCEL_GIT_COMMIT_SHA:0:12}/_next/static" \
- --endpoint-url "$ASSET_CDN_S3_ENDPOINT" \
- --cache-control "public,max-age=604800,immutable" \
- --region auto \
- --only-show-errors
-
-# Some public files may be referenced through CSS (relative path) and therefore they would be requested via the CDN url
-# To ensure we don't run into some nasty debugging issues, we upload the public files to the CDN as well
-echo -e "${YELLOW}Uploading public files to R2...${NC}"
-aws s3 sync "$PUBLIC_DIR" "s3://$BUCKET_NAME/$SITE_NAME/${VERCEL_GIT_COMMIT_SHA:0:12}" \
- --endpoint-url "$ASSET_CDN_S3_ENDPOINT" \
- --cache-control "public,max-age=604800,immutable" \
- --region auto \
- --only-show-errors
-
-echo -e "${GREEN}Upload completed successfully!${NC}"
-
-# Clean up local static files so we prevent a double upload
-echo -e "${YELLOW}Cleaning up local static files...${NC}"
-rm -rf "$STATIC_DIR"/*
-echo -e "${GREEN}Local static files cleaned up${NC}"
-
-# We still keep the public dir, as Next.js does not officially support serving the public files via CDN
\ No newline at end of file