🎥 Make videos programmatically with React
simplify: create-snapshot is production-only, remove dev branching
Jonny Burger58d2c3fb1db5
diff --git a/packages/template-vercel/create-snapshot.ts b/packages/template-vercel/create-snapshot.tsindex 36b88f66e8..ba98ccbe7c 100644--- a/packages/template-vercel/create-snapshot.ts+++ b/packages/template-vercel/create-snapshot.ts@@ -1,8 +1,6 @@import { createSandbox } from './src/app/api/render/sandbox/create-sandbox';import { saveSnapshotCache } from './src/app/api/render/sandbox/snapshots';-const SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000;-const sandbox = await createSandbox({onProgress: async (progress) => {if (progress.type === 'phase') {@@ -13,18 +11,10 @@ const sandbox = await createSandbox({});console.log('[create-snapshot] Taking snapshot...');-const snapshot = await sandbox.snapshot(- process.env.VERCEL ? { expiration: 0 } : undefined,-);--const expiresAt = process.env.VERCEL- ? undefined- : new Date(Date.now() + SEVEN_DAYS_MS);+const snapshot = await sandbox.snapshot({ expiration: 0 });-await saveSnapshotCache(snapshot.snapshotId, expiresAt);+await saveSnapshotCache(snapshot.snapshotId);console.log(- `[create-snapshot] Snapshot saved: ${snapshot.snapshotId}${- expiresAt ? ` (expires ${expiresAt.toISOString()})` : ' (never expires)'- }`,+ `[create-snapshot] Snapshot saved: ${snapshot.snapshotId} (never expires)`,);diff --git a/packages/template-vercel/src/app/api/render/sandbox/snapshots.ts b/packages/template-vercel/src/app/api/render/sandbox/snapshots.tsindex dbf6e61b30..90dd3299e0 100644--- a/packages/template-vercel/src/app/api/render/sandbox/snapshots.ts+++ b/packages/template-vercel/src/app/api/render/sandbox/snapshots.ts@@ -1,11 +1,10 @@-import { head, put } from "@vercel/blob";+import { head, put } from '@vercel/blob';type SnapshotCache = {snapshotId: string;- expiresAt?: string;};-const SNAPSHOT_BLOB_KEY = `snapshot-cache/${process.env.VERCEL_DEPLOYMENT_ID ?? "local"}.json`;+const SNAPSHOT_BLOB_KEY = `snapshot-cache/${process.env.VERCEL_DEPLOYMENT_ID ?? 'local'}.json`;export async function getCachedSnapshot(): Promise<string | null> {if (!process.env.VERCEL) {@@ -17,28 +16,20 @@ export async function getCachedSnapshot(): Promise<string | null> {const response = await fetch(metadata.url);const cache: SnapshotCache = await response.json();- if (cache.expiresAt && new Date(cache.expiresAt) < new Date()) {- return null;- }-return cache.snapshotId;} catch {return null;}}-export async function saveSnapshotCache(- snapshotId: string,- expiresAt?: Date,-): Promise<void> {+export async function saveSnapshotCache(snapshotId: string): Promise<void> {const cache: SnapshotCache = {snapshotId,- ...(expiresAt ? { expiresAt: expiresAt.toISOString() } : {}),};await put(SNAPSHOT_BLOB_KEY, JSON.stringify(cache), {- access: "public",- contentType: "application/json",+ access: 'public',+ contentType: 'application/json',addRandomSuffix: false,});}