Repository navigation
feat(cli): run a Remix app's own server in the console Preview, like the platform - #1029
Merged
Merged
Conversation
…the platform
A Remix project whose remix.json declares "server" now gets its server/ beside
the front: `wrangler dev` (workerd + a local D1) with a generated config that
carries the platform's bindings (D1 as DB with server/migrations applied first,
ROOMS -> Room with tag rooms-v1, the remix.json "env" names with values from the
project .env, secrets in a 0600 .dev.vars), state in .wrangler/state.
The app-server proxy puts it on the preview's own origin the way the platform
Worker does: /_v/local/{api,auth,webhooks,ws,__cron,__check-env} -> the server
with the prefix stripped and the X-Remix-* identity headers, and for a phone app
`globalThis.__REMIX_SERVER_BASE__ = "<public origin>/_v/local/"` is prepended to
every Metro JS bundle (web and Expo Go), so the app's code is not edited. Web
apps get their root server paths routed. killPreview stops both.
Expo now starts with EXPO_NO_TYPESCRIPT_SETUP=1: a Remix MOBILE export has .tsx
files and no typescript dependency, and a non-interactive `expo start` exited.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Owner, 2026-11-23: a Remix project's
server/has to work in the console Preview the same way it does on the Remix feed/player. Until now the Preview only started the client.What
remix-app-server.ts: whenremix.jsondeclares"server", the preview runswrangler dev(workerd + local D1). The generated config uses the platform's bindings fromremix-cloudflare.ts:2026-08-01+nodejs_compatDB, withserver/migrationsapplied first (wrangler d1 migrations apply DB --local)ROOMS→Room(migration tagrooms-v1)"env"names, with values read from the project.env. Secrets go in a 0600.dev.vars, never in argv..wrangler/stateand survives restarts.~/.codeam/tools(4.158.0 on Node ≥22, 4.85.0 on Node 20).app-server-proxy.ts: sits between cloudflared and the dev server and routes likedispatch.ts./_v/local/<server path>goes to wrangler with the prefix stripped and theX-Remix-*headers set (a client's forged ones are dropped). For phone apps it prependsglobalThis.__REMIX_SERVER_BASE__="<public origin>/_v/local/"to Metro JS bundles, for web and Expo Go alike. Web apps get their root server paths routed. No CORS, no second tunnel, no edits to the app's code.killPreview: the preview is ready once both the server and the dev server are up. Stop and restart kill both, and a failed bring-up kills the server.EXPO_NO_TYPESCRIPT_SETUP=1. A Remix MOBILE export has.tsxfiles and notypescriptdependency, and a non-interactiveexpo startwas exiting with an error.Verified live (local Mac)
Fixture: a Remix MOBILE export with
server/(Hono + D1 migration +src/api/client.tsreading__REMIX_SERVER_BASE__). It went through the realdetectKnownProject+runPreviewStart, with a real quick tunnel:globalThis.__REMIX_SERVER_BASE__="https://<tunnel>/_v/local/", for bothplatform=webandplatform=ios.POST /_v/local/api/items 201and the new row appeared.Tests
New
__tests__/preview/remix-app-server.test.ts(config generation,.dev.varspermissions, routing, prelude, identity headers, and a live proxy against fake servers).tscis clean. Full CLI suite: 3628 passed. The one failure (acp.adapterModuleGraph.int) also fails on main on this machine.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.