Skip to content

VC1: the apps on Workers - #2

Merged
ruehowl merged 1 commit into
mainfrom
vc/1-the-apps
Oct 29, 2026
Merged

ruehowl merged 1 commit into
mainfrom
vc/1-the-apps

Conversation

@ruehowl

@ruehowl ruehowl commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

The v0 SDK example's two apps, each its own Cloudflare Worker per environment, built by @opennextjs/cloudflare:

  • apps/web: the host app, with the chat UI, its server routes and the preview iframe.
  • apps/preview: upstream's apps/preview-proxy, on an origin of its own, so generated code never runs on the host's origin.

What replaces Vercel

Vercel Here
Related Projects told each app the other's URL Each build is told it instead: NEXT_PUBLIC_V0_PREVIEW_PROXY_URL and NEXT_PUBLIC_V0_CLONE_ORIGIN are inlined at build time. Each is the environment's override when set, else the sibling Worker's workers.dev URL (wired in VC3). next dev keeps localhost:3000/3001, as upstream does.
Vercel OIDC as the fallback credential Left out, because Cloudflare has no equivalent. The key is V0_API_KEY (optional), else the visitor's own, saved through the dialog into an HTTP-only cookie on each origin.
— V0_API_BASE_URL (unset in a product) points the v0 calls at another origin with the same paths. It exists for the stand-in v0 API in the e2e.

Also in this PR

  • A health route per app for the deploy's smoke. It names the other app's origin, and says whether a server key is set, never its value.
  • pnpm 10, Node 22 and the reference's ESLint. Next moves from 16.2.4 to 16.3.8, the reference's OpenNext-tested version.
  • The cookie and storage keys no longer carry the example's name.
  • Upstream's bun tests run under vitest in tests/web.
  • New tests in tests/web and tests/preview cover the origins, the health routes, the proxy's key route (CORS from the host only), trusted preview hosts, the same-origin seam and the v0 fetch override.

Checks run locally

  • pnpm typecheck, pnpm lint and pnpm test are green: 43 web tests and 19 preview tests.
  • Both Workers fit Workers Free: web is 2,173 KiB and preview 1,600 KiB gzipped.
  • Under wrangler dev, against a stand-in v0 API:
    • both Workers serve with no key;
    • the host's dialog validates a key;
    • the proxy accepts a key only from the host's origin;
    • a chat's preview is served through the proxy with v0's token.

Generated by Claude Code

The v0 SDK example's two apps, each its own Cloudflare Worker per
environment through @opennextjs/cloudflare: apps/web (the host — the chat
UI, its server routes and the preview iframe) and apps/preview (upstream's
apps/preview-proxy, the preview proxy on an origin of its own, so generated
code never runs on the host's).

What Vercel supplied around them is replaced:
- Related Projects told each app the other's URL. Each build is now told it
  instead: NEXT_PUBLIC_V0_PREVIEW_PROXY_URL and NEXT_PUBLIC_V0_CLONE_ORIGIN
  are inlined at build (the environment's override when set, else the
  sibling Worker's workers.dev URL — wired in VC3), and `next dev` still
  gets localhost:3000/3001 as upstream does. Origins are validated as
  before; plain HTTP is allowed on loopback only.
- Vercel OIDC, the fallback credential, has no Cloudflare equivalent and is
  left out: the key is V0_API_KEY (optional), else the visitor's own, saved
  through the dialog into an HTTP-only cookie on each origin.
- V0_API_BASE_URL (unset in a product) points the v0 calls at another
  origin with the same paths — the stand-in v0 API the e2e serves.

Also: a health route per app for the deploy's smoke (it names the other
app's origin, and whether a server key is set, never its value); pnpm 10 +
Node 22 and the reference's lint; Next 16.2.4 → 16.3.8 (the reference's
OpenNext-tested version); the cookie and storage keys no longer carry the
example's name. Upstream's bun tests run under vitest in tests/web, with new
tests in tests/web and tests/preview for the origins, health, the proxy's
key route (CORS from the host only), trusted preview hosts, the same-origin
seam and the v0 fetch override: 43 + 19 green.

Both Workers fit Workers Free (web 2,173 KiB, preview 1,600 KiB gzipped).
Under wrangler dev, against a stand-in v0 API: both serve with no key, the
host's dialog validates a key, the proxy accepts it only from the host's
origin, and a chat's preview is served through the proxy with v0's token.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019PcpNVpFBcbeiX3EHdXfmn
@ruehowl
ruehowl merged commit 2d01fb5 into main Oct 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants