Open source CapCut alternative.
TypeScript
refactor(site): drop the route segment configs Cache Components rejects
David Le3a333855ee2d
diff --git a/site/src/app/api/account/avatar/route.ts b/site/src/app/api/account/avatar/route.tsindex 7f9ebbf1..2dbb7659 100644--- a/site/src/app/api/account/avatar/route.ts+++ b/site/src/app/api/account/avatar/route.ts@@ -8,8 +8,6 @@ import {import { accountProfile } from "@/lib/account-profile";import { prisma } from "@/lib/prisma";-export const dynamic = "force-dynamic";-// The client crops to a square and re-encodes before uploading, so anything// arriving here is already small. The cap is a backstop against a caller that// skips that path, not a size the UI ever approaches.diff --git a/site/src/app/api/account/email-preferences/route.ts b/site/src/app/api/account/email-preferences/route.tsindex bf326e6d..6da36fb5 100644--- a/site/src/app/api/account/email-preferences/route.ts+++ b/site/src/app/api/account/email-preferences/route.ts@@ -10,8 +10,6 @@ import {setMarketingUnsubscribed,} from "@/lib/email/unsubscribe";-export const dynamic = "force-dynamic";-export const GET = withDonkeyAuth(async (request: DonkeyAuthenticatedRequest) => {return NextResponse.json({diff --git a/site/src/app/api/account/me/route.ts b/site/src/app/api/account/me/route.tsindex 2cc297a4..1057c233 100644--- a/site/src/app/api/account/me/route.ts+++ b/site/src/app/api/account/me/route.ts@@ -3,8 +3,6 @@ import { NextResponse } from "next/server";import { withDonkeyAuth } from "@/lib/donkey-api-auth";import { prisma } from "@/lib/prisma";-export const dynamic = "force-dynamic";-// Minimal identity for the settings UI: who am I, and am I a super user (which// gates the manual credit-grant card). Session-only.export const GET = withDonkeyAuth(async (request) => {diff --git a/site/src/app/api/account/onboarding/route.ts b/site/src/app/api/account/onboarding/route.tsindex b18ec379..0f26bdf2 100644--- a/site/src/app/api/account/onboarding/route.ts+++ b/site/src/app/api/account/onboarding/route.ts@@ -13,8 +13,6 @@ import {} from "@/lib/onboarding/sequence";import { prisma } from "@/lib/prisma";-export const dynamic = "force-dynamic";-type OnboardingState = {version: number;completedAt: string | null;diff --git a/site/src/app/api/account/profile/route.ts b/site/src/app/api/account/profile/route.tsindex 6289a1b8..7fe1a7e8 100644--- a/site/src/app/api/account/profile/route.ts+++ b/site/src/app/api/account/profile/route.ts@@ -10,8 +10,6 @@ import {import { validationErrorResponse } from "@/lib/inference/responses";import { prisma } from "@/lib/prisma";-export const dynamic = "force-dynamic";-// The visible name is the product's own field. `name` keeps whatever Google// gave us at sign-in — billing and the provider record depend on it — so a// user renaming themselves writes `displayName`, and clearing it falls back todiff --git a/site/src/app/api/analytics/rollup/route.ts b/site/src/app/api/analytics/rollup/route.tsindex 1d943fb1..1e99739e 100644--- a/site/src/app/api/analytics/rollup/route.ts+++ b/site/src/app/api/analytics/rollup/route.ts@@ -4,8 +4,6 @@ import { getObject, R2NotConfiguredError } from "@/cut/server/cloud/r2";import { ROLLUP_KEY } from "@/lib/analytics/pipeline";import { withSuperUser } from "@/lib/donkey-api-auth";-export const dynamic = "force-dynamic";-// The consolidated analytics JSON, passed through exactly as the nightly job// wrote it. It carries emails and balances, so it stays behind the super-user// gate; the dashboard reads this and never the database.diff --git a/site/src/app/api/analytics/run/route.ts b/site/src/app/api/analytics/run/route.tsindex 7176241a..43906a51 100644--- a/site/src/app/api/analytics/run/route.ts+++ b/site/src/app/api/analytics/run/route.ts@@ -3,7 +3,6 @@ import { NextRequest, NextResponse } from "next/server";import { isVercelCron, notFoundResponse } from "@/lib/donkey-api-auth";import { enqueueJob } from "@/lib/jobs/queue";-export const dynamic = "force-dynamic";// Without a queue configured (local dev) the job runs inline before the// response; give it room.export const maxDuration = 300;diff --git a/site/src/app/api/api-keys/[id]/route.ts b/site/src/app/api/api-keys/[id]/route.tsindex 420a5026..8bebe7d1 100644--- a/site/src/app/api/api-keys/[id]/route.ts+++ b/site/src/app/api/api-keys/[id]/route.ts@@ -7,8 +7,6 @@ import {} from "@/lib/donkey-api-auth";import { prisma } from "@/lib/prisma";-export const runtime = "nodejs";-/** Revoke a key. The row stays for the audit trail; `enabled: false` stops* matching live traffic immediately. */export const DELETE = withDonkeyAuth(async (request, ctx: { params: Promise<{ id: string }> }) => {diff --git a/site/src/app/api/api-keys/route.ts b/site/src/app/api/api-keys/route.tsindex e8571ff5..6be4c41a 100644--- a/site/src/app/api/api-keys/route.ts+++ b/site/src/app/api/api-keys/route.ts@@ -14,8 +14,6 @@ import { prisma } from "@/lib/prisma";// keys. The full secret is returned once, at creation; the row holds its// hash (`key`) and a display head (`start`).-export const runtime = "nodejs";-const MAX_KEYS = 20;export const GET = withDonkeyAuth(async (request) => {diff --git a/site/src/app/api/billing/checkout/route.ts b/site/src/app/api/billing/checkout/route.tsindex 24f6648f..459a7672 100644--- a/site/src/app/api/billing/checkout/route.ts+++ b/site/src/app/api/billing/checkout/route.ts@@ -9,8 +9,6 @@ import {withDonkeyAuth,} from "@/lib/donkey-api-auth";-export const dynamic = "force-dynamic";-// Start a Stripe Checkout session for a Pro subscription. This route keeps its// getSession call because it needs the user's email/name.export const POST = withDonkeyAuth(async (request) => {diff --git a/site/src/app/api/billing/credits/auto-reload/route.ts b/site/src/app/api/billing/credits/auto-reload/route.tsindex 14c6007c..b6cd07ac 100644--- a/site/src/app/api/billing/credits/auto-reload/route.ts+++ b/site/src/app/api/billing/credits/auto-reload/route.ts@@ -9,8 +9,6 @@ import {import { withDonkeyAuth } from "@/lib/donkey-api-auth";import { prisma } from "@/lib/prisma";-export const dynamic = "force-dynamic";-// Defaults shown before the user has saved any config.const defaultThresholdDollars = 10;const defaultAmountDollars = 25;diff --git a/site/src/app/api/billing/credits/checkout/route.ts b/site/src/app/api/billing/credits/checkout/route.tsindex f677d693..99ddd77b 100644--- a/site/src/app/api/billing/credits/checkout/route.ts+++ b/site/src/app/api/billing/credits/checkout/route.ts@@ -11,8 +11,6 @@ import {} from "@/lib/credits/top-up";import { unauthorizedResponse, withDonkeyAuth } from "@/lib/donkey-api-auth";-export const dynamic = "force-dynamic";-const checkoutRequestSchema = z.object({amountDollars: z.coercediff --git a/site/src/app/api/billing/portal/route.ts b/site/src/app/api/billing/portal/route.tsindex a9f0d2af..0a4e2980 100644--- a/site/src/app/api/billing/portal/route.ts+++ b/site/src/app/api/billing/portal/route.ts@@ -9,8 +9,6 @@ import {} from "@/lib/donkey-api-auth";import { prisma } from "@/lib/prisma";-export const dynamic = "force-dynamic";-// Open the Stripe billing portal for the signed-in customer.export const POST = withDonkeyAuth(async (request) => {const userId = donkeySessionUserId(request);diff --git a/site/src/app/api/billing/pro/route.ts b/site/src/app/api/billing/pro/route.tsindex d6d7e43e..0340fa70 100644--- a/site/src/app/api/billing/pro/route.ts+++ b/site/src/app/api/billing/pro/route.ts@@ -6,8 +6,6 @@ import { creditGrantUnit } from "@/lib/credits/inference";import { withDonkeyAuth } from "@/lib/donkey-api-auth";import { prisma } from "@/lib/prisma";-export const dynamic = "force-dynamic";-// Pro subscription status for the settings UI, plus how much of this period's// included allowance is left — the remaining balance on the active// "pro_subscription" grant(s).diff --git a/site/src/app/api/billing/usage/route.ts b/site/src/app/api/billing/usage/route.tsindex 7c6f03b9..7b105624 100644--- a/site/src/app/api/billing/usage/route.ts+++ b/site/src/app/api/billing/usage/route.ts@@ -11,8 +11,6 @@ import {} from "@/lib/donkey-api-auth";import { prisma } from "@/lib/prisma";-export const dynamic = "force-dynamic";-// Up to 5 pages of 25 in the usage tab.const recentLimit = 125;diff --git a/site/src/app/api/billing/webhook/route.ts b/site/src/app/api/billing/webhook/route.tsindex 9bc695e7..bd7ae195 100644--- a/site/src/app/api/billing/webhook/route.ts+++ b/site/src/app/api/billing/webhook/route.ts@@ -14,8 +14,6 @@ import {import { getStripe, stripeId } from "@/lib/billing/stripe";import { notFoundResponse } from "@/lib/donkey-api-auth";-export const dynamic = "force-dynamic";-// Pro is the only subscription product; ignore any other Stripe subscription// that reaches these webhook events.async function syncSubscription(subscription: Stripe.Subscription) {diff --git a/site/src/app/api/browser/run/route.ts b/site/src/app/api/browser/run/route.tsindex 07091642..6ebebf28 100644--- a/site/src/app/api/browser/run/route.ts+++ b/site/src/app/api/browser/run/route.ts@@ -20,7 +20,6 @@ import {validationErrorResponse,} from "@/lib/inference/responses";-export const dynamic = "force-dynamic";// The run executes server-side to completion (the SDK polls Browser Use here, not// the app), so the function must be allowed to run long. maxCostUsd bounds the// task so it finishes well within this.diff --git a/site/src/app/api/credits/balance/route.ts b/site/src/app/api/credits/balance/route.tsindex 2bd2bf98..730f9e72 100644--- a/site/src/app/api/credits/balance/route.ts+++ b/site/src/app/api/credits/balance/route.ts@@ -3,8 +3,6 @@ import { NextResponse } from "next/server";import { getCreditBalance } from "@/lib/credits/inference";import { withDonkeyAuth } from "@/lib/donkey-api-auth";-export const dynamic = "force-dynamic";-export const GET = withDonkeyAuth(async (request) => {const balance = await getCreditBalance(request.donkey.userId);diff --git a/site/src/app/api/credits/grants/route.ts b/site/src/app/api/credits/grants/route.tsindex ab4a1bf1..aa20e660 100644--- a/site/src/app/api/credits/grants/route.ts+++ b/site/src/app/api/credits/grants/route.ts@@ -7,8 +7,6 @@ import { maxCreditGrantDollars } from "@/lib/credits/top-up";import { notFoundResponse, withSuperUser } from "@/lib/donkey-api-auth";import { prisma } from "@/lib/prisma";-export const dynamic = "force-dynamic";-// The target is identified by userId (grant to self) or by email (grant to// another user). At least one is required. A single grant is capped to guard// against typos.diff --git a/site/src/app/api/cut-cloud/[[...slug]]/route.ts b/site/src/app/api/cut-cloud/[[...slug]]/route.tsindex de239219..5467e627 100644--- a/site/src/app/api/cut-cloud/[[...slug]]/route.ts+++ b/site/src/app/api/cut-cloud/[[...slug]]/route.ts@@ -7,7 +7,6 @@ import { cutCloudCatchAll } from "@/cut/server/cloud/routes";// session cookie (withDonkeyAuth) and dispatches through the cloud route table// (src/cut/server/cloud/routes.ts). The client's cloud driver rewrites the// engine's /api/cut/* paths to this prefix.-export const runtime = "nodejs";// The Cut API surface takes machine callers: a `dk_live_` bearer key acts as// its user across the same routes the page uses, and the Cut runner callsdiff --git a/site/src/app/api/cut-copy-worker/route.ts b/site/src/app/api/cut-copy-worker/route.tsindex 71b25778..16043d6e 100644--- a/site/src/app/api/cut-copy-worker/route.ts+++ b/site/src/app/api/cut-copy-worker/route.ts@@ -6,7 +6,6 @@ import { executeCopyJob } from "@/cut/server/cloud/copyQueue";// Deliberately not wrapped in withDonkeyAuth — the caller is a machine, not a// session — and gated by the shared secret instead, like the render worker's// wake in the other direction.-export const runtime = "nodejs";// A big project copies many R2 objects; give the function room to finish.export const maxDuration = 300;diff --git a/site/src/app/api/cut-shared/[[...slug]]/route.ts b/site/src/app/api/cut-shared/[[...slug]]/route.tsindex 61a5ba57..5a7660de 100644--- a/site/src/app/api/cut-shared/[[...slug]]/route.ts+++ b/site/src/app/api/cut-shared/[[...slug]]/route.ts@@ -6,7 +6,6 @@ import { cutSharedCatchAll } from "@/cut/server/cloud/sharedRoutes";// docs/guides/backend-apis.md). Access control happens per request inside the// route table's share resolver, and content is filtered to the share's// settings before it leaves the server.-export const runtime = "nodejs";const handle = (request: Request) => cutSharedCatchAll(request);diff --git a/site/src/app/api/cut/[[...slug]]/route.ts b/site/src/app/api/cut/[[...slug]]/route.tsindex 5f1fddc4..30ae5f52 100644--- a/site/src/app/api/cut/[[...slug]]/route.ts+++ b/site/src/app/api/cut/[[...slug]]/route.ts@@ -10,7 +10,6 @@ import { isHostedRuntime } from "@/cut/server/local-only";// on hosted builds next.config aliases "@/cut/server/http/next" to a 404 stub,// keeping the engine (and the ~220MB SDK CLI binary it would otherwise sweep in)// out of the deployed function so it fits Vercel's size limit.-export const runtime = "nodejs";async function handle(req: Request): Promise<Response> {if (isHostedRuntime()) return new Response(null, { status: 404 });diff --git a/site/src/app/api/email/resend-webhook/route.ts b/site/src/app/api/email/resend-webhook/route.tsindex 34dfed6b..263db7d0 100644--- a/site/src/app/api/email/resend-webhook/route.ts+++ b/site/src/app/api/email/resend-webhook/route.ts@@ -6,8 +6,6 @@ import { unauthorizedResponse } from "@/lib/donkey-api-auth";import { setMarketingUnsubscribed } from "@/lib/email/unsubscribe";import { prisma } from "@/lib/prisma";-export const dynamic = "force-dynamic";-// The one event this app consumes: an unsubscribe (or resubscribe) made on// Resend's side — a broadcast footer link or a dashboard edit — flows back// into the account's own preference row. Everything else acknowledges as adiff --git a/site/src/app/api/email/unsubscribe/route.ts b/site/src/app/api/email/unsubscribe/route.tsindex 0729daf8..499ad4e6 100644--- a/site/src/app/api/email/unsubscribe/route.ts+++ b/site/src/app/api/email/unsubscribe/route.ts@@ -7,8 +7,6 @@ import {verifyUnsubscribeToken,} from "@/lib/email/unsubscribe";-export const dynamic = "force-dynamic";-const querySchema = z.object({ token: z.string().min(1).max(512) });// Public exception to withDonkeyAuth (docs/guides/backend-apis.md): RFC 8058diff --git a/site/src/app/api/health/route.ts b/site/src/app/api/health/route.tsindex 3ca4373b..814bcf6a 100644--- a/site/src/app/api/health/route.ts+++ b/site/src/app/api/health/route.ts@@ -1,8 +1,9 @@-import { NextResponse } from "next/server";+import { connection, NextResponse } from "next/server";-export const dynamic = "force-dynamic";--export function GET() {+export async function GET() {+ // A health check answers for the running deployment: awaiting the connection+ // holds the handler until a real request arrives, so the env is read then.+ await connection();return NextResponse.json({ok: true,services: {diff --git a/site/src/app/api/inference/assets/refresh/route.ts b/site/src/app/api/inference/assets/refresh/route.tsindex 4f19cba3..dd6e5769 100644--- a/site/src/app/api/inference/assets/refresh/route.ts+++ b/site/src/app/api/inference/assets/refresh/route.ts@@ -16,8 +16,6 @@ import { storedGenerationForProviderSchema } from "@/lib/inference/schemas";import { withDonkeyAuth } from "@/lib/donkey-api-auth";import { InferenceProviderError } from "@/lib/inference/providers";-export const dynamic = "force-dynamic";-export const POST = withDonkeyAuth(async (request) => {const client = requireInferenceClientId(request.donkey.clientId);if (!client.ok) {diff --git a/site/src/app/api/inference/assets/route.ts b/site/src/app/api/inference/assets/route.tsindex 1e9c65ea..3f00eff5 100644--- a/site/src/app/api/inference/assets/route.ts+++ b/site/src/app/api/inference/assets/route.ts@@ -25,8 +25,6 @@ import { resolveInferenceBlobs } from "@/lib/inference/blobs";import { InferenceProviderError, type JsonObject } from "@/lib/inference/providers";import { toJsonObject, toJsonValue } from "@/lib/inference/json";-export const dynamic = "force-dynamic";-// Music generation (Gemini/Lyria) polls its render to completion in-request, so// the handler can stay open longer than the platform default. Image, video, and// speech return well inside this; it is a ceiling, not a delay.diff --git a/site/src/app/api/inference/chat/completions/route.ts b/site/src/app/api/inference/chat/completions/route.tsindex 263f2c0b..a757729d 100644--- a/site/src/app/api/inference/chat/completions/route.ts+++ b/site/src/app/api/inference/chat/completions/route.ts@@ -24,8 +24,6 @@ import {} from "@/lib/donkey-api-auth";import { InferenceProviderError } from "@/lib/inference/providers";-export const dynamic = "force-dynamic";-export const POST = withDonkeyAuth(async (request) => {const client = requireInferenceClientId(request.donkey.clientId);if (!client.ok) {diff --git a/site/src/app/api/inference/live-token/route.ts b/site/src/app/api/inference/live-token/route.tsindex b2da3e3f..045ccaad 100644--- a/site/src/app/api/inference/live-token/route.ts+++ b/site/src/app/api/inference/live-token/route.ts@@ -4,8 +4,6 @@ import { withDonkeyAuth } from "@/lib/donkey-api-auth";import { requireInferenceClientId } from "@/lib/inference/responses";import { mintVertexLiveConnection } from "@/lib/inference/vertex-live";-export const dynamic = "force-dynamic";-// Mints a short-lived Vertex AI access token so a Donkey client can open a// Gemini Live websocket directly. The long-lived service-account credential// stays on the backend. Errors propagate raw.diff --git a/site/src/app/api/inference/models/route.ts b/site/src/app/api/inference/models/route.tsindex b3598614..375c26bb 100644--- a/site/src/app/api/inference/models/route.ts+++ b/site/src/app/api/inference/models/route.ts@@ -5,8 +5,6 @@ import { requireInferenceClientId } from "@/lib/inference/responses";import { parseRequestedModalities } from "@/lib/inference/schemas";import { withDonkeyAuth } from "@/lib/donkey-api-auth";-export const dynamic = "force-dynamic";-export const GET = withDonkeyAuth(async (request) => {const client = requireInferenceClientId(request.donkey.clientId);if (!client.ok) {diff --git a/site/src/app/api/inference/responses/route.ts b/site/src/app/api/inference/responses/route.tsindex f7bddadd..60748e42 100644--- a/site/src/app/api/inference/responses/route.ts+++ b/site/src/app/api/inference/responses/route.ts@@ -24,8 +24,6 @@ import {withDonkeyAuth,} from "@/lib/donkey-api-auth";-export const dynamic = "force-dynamic";-export const POST = withDonkeyAuth(async (request) => {const client = requireInferenceClientId(request.donkey.clientId);if (!client.ok) {diff --git a/site/src/app/api/inference/uploads/route.ts b/site/src/app/api/inference/uploads/route.tsindex b8e852a5..9d98447c 100644--- a/site/src/app/api/inference/uploads/route.ts+++ b/site/src/app/api/inference/uploads/route.ts@@ -13,8 +13,6 @@ import {import { inferenceUploadRequestSchema } from "@/lib/inference/schemas";import { withDonkeyAuth } from "@/lib/donkey-api-auth";-export const dynamic = "force-dynamic";-// Media a hosted inference call carries rides object storage rather than the// request body (see lib/inference/blobs.ts). This mints the upload URLs: one// content-addressed key per picture or sound, and a direct PUT the browser sendsdiff --git a/site/src/app/api/jobs/[jobId]/route.ts b/site/src/app/api/jobs/[jobId]/route.tsindex ca4d4489..67fdb814 100644--- a/site/src/app/api/jobs/[jobId]/route.ts+++ b/site/src/app/api/jobs/[jobId]/route.ts@@ -2,8 +2,6 @@ import { notFoundResponse, withSuperUser } from "@/lib/donkey-api-auth";import { jobStatusResponse } from "@/lib/jobs/queue";import { prisma } from "@/lib/prisma";-export const dynamic = "force-dynamic";-type RouteContext = { params: Promise<{ jobId: string }> };// Poll one background job for its outcome.diff --git a/site/src/app/api/jobs/route.ts b/site/src/app/api/jobs/route.tsindex c4ae3eb8..63aa7c23 100644--- a/site/src/app/api/jobs/route.ts+++ b/site/src/app/api/jobs/route.ts@@ -7,7 +7,6 @@ import { enqueueJob, healJob } from "@/lib/jobs/queue";import { jobKinds } from "@/lib/jobs/registry";import { prisma } from "@/lib/prisma";-export const dynamic = "force-dynamic";// Without a queue configured (local dev) the job runs inline before the// response; give it room.export const maxDuration = 300;diff --git a/site/src/app/api/jobs/worker/route.ts b/site/src/app/api/jobs/worker/route.tsindex 42f05820..654908ea 100644--- a/site/src/app/api/jobs/worker/route.ts+++ b/site/src/app/api/jobs/worker/route.ts@@ -7,7 +7,7 @@ import { executeJob } from "@/lib/jobs/queue";// Deliberately not wrapped in withDonkeyAuth — the caller is a machine, not a// session — and gated by the shared secret instead, like the copy worker's// callback beside it.-export const runtime = "nodejs";+// A user delete can move a lot of R2 objects; give the function room to finish.export const maxDuration = 300;diff --git a/site/src/app/api/web/fetch/route.ts b/site/src/app/api/web/fetch/route.tsindex a62bc423..f8bb36b4 100644--- a/site/src/app/api/web/fetch/route.ts+++ b/site/src/app/api/web/fetch/route.ts@@ -8,8 +8,6 @@ import {} from "@/lib/inference/responses";import { fetchWebContent } from "@/lib/inference/web-fetch";-export const dynamic = "force-dynamic";-const webFetchRequestSchema = z.object({url: z.string().trim().url().max(2000),});diff --git a/site/src/app/api/web/search/route.ts b/site/src/app/api/web/search/route.tsindex ddc3c4eb..13961956 100644--- a/site/src/app/api/web/search/route.ts+++ b/site/src/app/api/web/search/route.ts@@ -8,8 +8,6 @@ import {} from "@/lib/inference/responses";import { searchWeb } from "@/lib/inference/web-search";-export const dynamic = "force-dynamic";-const webSearchRequestSchema = z.object({query: z.string().trim().min(1).max(500),});diff --git a/site/src/app/cut/s/[token]/card/[ext]/route.ts b/site/src/app/cut/s/[token]/card/[ext]/route.tsindex 678bfbf7..af8a0575 100644--- a/site/src/app/cut/s/[token]/card/[ext]/route.ts+++ b/site/src/app/cut/s/[token]/card/[ext]/route.ts@@ -18,8 +18,6 @@ import {// so the answer depends on the viewer's session and must stay out of shared// caches.-export const runtime = "nodejs";-export async function GET(request: Request,{ params }: { params: Promise<{ token: string; ext: string }> }