Open source CapCut alternative.
TypeScript
perf(site): keep the starter media out of every function's bundle
David Lec35ec502ef3a
diff --git a/docs/guides/backend-apis.md b/docs/guides/backend-apis.mdindex ab2a9de6..7a96c8b3 100644--- a/docs/guides/backend-apis.md+++ b/docs/guides/backend-apis.md@@ -55,6 +55,10 @@ challenge. OAuth tokens authorize only the tools exposed by that adapter.402 over quota, 429 rate-limited.- Don't wrap a handler in try/catch unless it can recover and return a differentintentional response. Let unexpected errors surface to the framework.+- What a handler imports is what its serverless function downloads before it can+ answer anything. Import the narrow module that holds what you need, and when a+ module reads files from the public folder, keep those bytes out of every other+ function with `outputFileTracingExcludes` in the Next config.- `process.env` holds secrets only: API keys, credentials, and other sensitivedeploy values. Configuration is code: a constant where one value fits everyinstall, or a settings registry entry with a default and a schema whendiff --git a/site/next.config.ts b/site/next.config.tsindex ae9d501b..46313bfb 100644--- a/site/next.config.ts+++ b/site/next.config.ts@@ -22,6 +22,15 @@ const nextConfig: NextConfig = {// Keep the server origin intact when the proxy rewrites a local request.// Normalizing 127.0.0.1 to localhost makes Next treat it as an external hop.skipProxyUrlNormalize: true,+ // The starter project's media is 54MB. Signup seeding reads the public folder+ // (src/cut/server/cloud/starter.ts), every route that authenticates imports+ // that module through src/lib/auth.ts, and tracing therefore put those bytes+ // in every function — a 69MB download before a cold function could answer a+ // JSON request. Signup is the one route that reads them, so it keeps them,+ // and it holds its own fallback besides: the media rides an R2 mirror, and a+ // file missing from the mirror is fetched from the CDN.+ outputFileTracingExcludes: { "/**": ["public/cut-starter/media/**"] },+ outputFileTracingIncludes: { "/api/auth/*": ["public/cut-starter/media/**"] },// Cut (the video editor) uploads large media. Two independent limits apply:// its media route reads req.formData() (a route handler), so it isn't covered// by serverActions.bodySizeLimit; and src/proxy.ts runs on /api/cut/* on every