Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Fix Vercel React Router deployment output (#58)

Graham Neubig96c237261f67
diff --git a/.gitignore b/.gitignore
index cb7e264d39..9df99a5cfb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ build/
/playwright/.cache/
.react-router/
ralph/
+.vercel
diff --git a/AGENTS.md b/AGENTS.md
index 6b32832857..3f03fd29ef 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -69,6 +69,7 @@
- Keep README user-focused and move contributor/developer-specific workflows (Cloud sandbox debugging, `dev:safe`, mock mode, detailed env vars/build-test notes) into `DEVELOPMENT.md`.
- `scripts/dev-safe.mjs` should fail fast if `agent-server` cannot be spawned (for example missing PATH entries).
- Vite dev mode can black-screen on first load with `504 Outdated Optimize Dep` if core client-entry deps are not prebundled; keep `react`, `react/jsx-runtime`, `react-dom/client`, and `react-router/dom` in `optimizeDeps.include`.
+- Vercel deployment note: React Router builds for this repo must keep `build/client` intact on actual Vercel builds and include `presets: [vercelPreset()]` from `@vercel/react-router/vite`; flattening `build/client` during a Vercel build produces deployments with empty outputs (`routes: null`, no static files) and a production 404.
- As an OpenHands incubator **Sandbox** project, the repo should carry the standard sandbox warning badge in `README.md` and include a root `LICENSE` file to satisfy the incubator-program requirements.
- OpenHands repo bootstrap files live under `.openhands/`:
diff --git a/package-lock.json b/package-lock.json
index 782c6c2294..e67d46eb5c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -67,6 +67,7 @@
"@types/react-syntax-highlighter": "15.5.13",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
+ "@vercel/react-router": "1.2.6",
"@vitest/coverage-v8": "4.1.4",
"cross-env": "10.1.0",
"eslint": "8.57.1",
@@ -94,7 +95,11 @@
"engines": {
"node": ">=22.12.0"
},
- "private": false
+ "peerDependencies": {
+ "react": "19.2.5",
+ "react-dom": "19.2.5",
+ "react-router": "7.14.1"
+ }
},
"node_modules/@adobe/css-tools": {
"version": "4.4.4",
@@ -4065,6 +4070,43 @@
"@testing-library/dom": ">=7.21.4"
}
},
+ "node_modules/@ts-morph/common": {
+ "version": "0.11.1",
+ "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.11.1.tgz",
+ "integrity": "sha512-7hWZS0NRpEsNV8vWJzg7FEz6V8MaLNeJOmwmghqUXTpzk16V1LLZhdo+4QvE/+zv4cVci0OviuJFnqhEfoV3+g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fast-glob": "^3.2.7",
+ "minimatch": "^3.0.4",
+ "mkdirp": "^1.0.4",
+ "path-browserify": "^1.0.1"
+ }
+ },
+ "node_modules/@ts-morph/common/node_modules/brace-expansion": {
+ "version": "1.1.14",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz",
+ "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "balanced-match": "^1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "node_modules/@ts-morph/common/node_modules/minimatch": {
+ "version": "3.1.5",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
+ "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "brace-expansion": "^1.1.7"
+ },
+ "engines": {
+ "node": "*"
+ }
+ },
"node_modules/@tybys/wasm-util": {
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz",
@@ -4132,6 +4174,13 @@
"@types/unist": "*"
}
},
+ "node_modules/@types/json-schema": {
+ "version": "7.0.15",
+ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
+ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@types/json5": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
@@ -4689,6 +4738,60 @@
"integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==",
"license": "ISC"
},
+ "node_modules/@vercel/react-router": {
+ "version": "1.2.6",
+ "resolved": "https://registry.npmjs.org/@vercel/react-router/-/react-router-1.2.6.tgz",
+ "integrity": "sha512-8+n/roFtLhpkq6dMAXXSWf4N5Uypckh2E8Uxduh+tdE+Z9AG4KXfFzGyHoyFYZqoUh6jgwsiFkDokSAymm4NHg==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@vercel/static-config": "3.2.0",
+ "ts-morph": "12.0.0"
+ },
+ "peerDependencies": {
+ "@react-router/dev": "7",
+ "@react-router/node": "7",
+ "isbot": "5",
+ "react": ">=18",
+ "react-dom": ">=18"
+ }
+ },
+ "node_modules/@vercel/static-config": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/@vercel/static-config/-/static-config-3.2.0.tgz",
+ "integrity": "sha512-UpOEIgWxWx0M+mDe1IMdHS6JuWM/L5nNIJ4ixX8v9JgBAejymo88OkgnmfLCNMem0Wd+b5vcQPWLdZybCndlsA==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "ajv": "8.6.3",
+ "json-schema-to-ts": "1.6.4",
+ "ts-morph": "12.0.0"
+ }
+ },
+ "node_modules/@vercel/static-config/node_modules/ajv": {
+ "version": "8.6.3",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.3.tgz",
+ "integrity": "sha512-SMJOdDP6LqTkD0Uq8qLi+gMwSt0imXLSV080qFVwJCpH9U6Mb+SUGHAXM0KNbcBPguytWyvFxcHgMLe2D2XSpw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fast-deep-equal": "^3.1.1",
+ "json-schema-traverse": "^1.0.0",
+ "require-from-string": "^2.0.2",
+ "uri-js": "^4.2.2"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/epoberezkin"
+ }
+ },
+ "node_modules/@vercel/static-config/node_modules/json-schema-traverse": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
+ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@vitest/coverage-v8": {
"version": "4.1.4",
"resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.4.tgz",
@@ -5803,6 +5906,13 @@
"node": ">=6"
}
},
+ "node_modules/code-block-writer": {
+ "version": "10.1.1",
+ "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-10.1.1.tgz",
+ "integrity": "sha512-67ueh2IRGst/51p0n6FvPrnRjAGHY5F8xdjkgrYE7DDzpJe6qA07RYQ9VcoUeo5ATOjSOiWpSL3SWBRRbempMw==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/color": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz",
@@ -9364,6 +9474,17 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/json-schema-to-ts": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/json-schema-to-ts/-/json-schema-to-ts-1.6.4.tgz",
+ "integrity": "sha512-pR4yQ9DHz6itqswtHCm26mw45FSNfQ9rEQjosaZErhn5J3J2sIViQiz8rDaezjKAhFGpmsoczYVBgGHzFw/stA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/json-schema": "^7.0.6",
+ "ts-toolbelt": "^6.15.5"
+ }
+ },
"node_modules/json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
@@ -11050,6 +11171,19 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/mkdirp": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
+ "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "mkdirp": "bin/cmd.js"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/monaco-editor": {
"version": "0.55.1",
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.55.1.tgz",
@@ -11735,6 +11869,13 @@
"node": ">= 0.8"
}
},
+ "node_modules/path-browserify": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz",
+ "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
@@ -13995,6 +14136,24 @@
"typescript": ">=4.2.0"
}
},
+ "node_modules/ts-morph": {
+ "version": "12.0.0",
+ "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-12.0.0.tgz",
+ "integrity": "sha512-VHC8XgU2fFW7yO1f/b3mxKDje1vmyzFXHWzOYmKEkCEwcLjDtbdLgBQviqj4ZwP4MJkQtRo6Ha2I29lq/B+VxA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@ts-morph/common": "~0.11.0",
+ "code-block-writer": "^10.1.1"
+ }
+ },
+ "node_modules/ts-toolbelt": {
+ "version": "6.15.5",
+ "resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-6.15.5.tgz",
+ "integrity": "sha512-FZIXf1ksVyLcfr7M317jbB67XFJhOO1YqdTcuGaq9q5jLUoTikukZ+98TPjKiP2jC5CgmYdWWYs0s2nLSU0/1A==",
+ "dev": true,
+ "license": "Apache-2.0"
+ },
"node_modules/tsconfig-paths": {
"version": "3.15.0",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz",
diff --git a/package.json b/package.json
index 45dd536f2c..8a931be14d 100644
--- a/package.json
+++ b/package.json
@@ -103,6 +103,7 @@
"@types/react-syntax-highlighter": "15.5.13",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
+ "@vercel/react-router": "1.2.6",
"@vitest/coverage-v8": "4.1.4",
"cross-env": "10.1.0",
"eslint": "8.57.1",
diff --git a/react-router.config.ts b/react-router.config.ts
index 216284fa71..0b4ab46f97 100644
--- a/react-router.config.ts
+++ b/react-router.config.ts
@@ -1,4 +1,5 @@
import type { Config } from "@react-router/dev/config";
+import { vercelPreset } from "@vercel/react-router/vite";
/**
* This script is used to unpack the client directory from the frontend build directory.
@@ -9,6 +10,11 @@ import type { Config } from "@react-router/dev/config";
* This script is used in the buildEnd function of the Vite config.
*/
const unpackClientDirectory = async () => {
+ if (process.env.VERCEL) {
+ // Vercel's React Router builder reads static assets from build/client.
+ return;
+ }
+
const fs = await import("fs");
const path = await import("path");
@@ -31,5 +37,6 @@ const unpackClientDirectory = async () => {
export default {
appDirectory: "src",
buildEnd: unpackClientDirectory,
+ presets: [vercelPreset()],
ssr: false,
} satisfies Config;