Open
Description
Provide environment information
System:
OS: macOS 15.4.1
CPU: (16) arm64 Apple M4 Max
Memory: 2.15 GB / 48.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.12.0 - ~/.volta/tools/image/node/22.12.0/bin/node
npm: 10.9.0 - ~/.volta/tools/image/node/22.12.0/bin/npm
pnpm: 10.5.1 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 136.0.7103.93
Safari: 18.4
npmPackages:
@tanstack/react-query: catalog:tanstack => 5.75.5
@trpc/client: catalog:trpc => 11.1.2
@trpc/server: catalog:trpc => 11.1.2
react: catalog:react19 => 19.1.0
typescript: catalog: => 5.8.3
Describe the bug
Starter doesn't work when deployed to Cloudflare. More specifically calling trpc on the loaders completely breaks the app and we get the following error:
Unexpected token '<', "<!DOCTYPE html>" is not valid JSON
Link to reproduction
https://github.com/trpc/trpc/tree/main/examples/tanstack-start
To reproduce
Download the trpc starter: https://github.com/trpc/trpc/tree/main/examples/tanstack-start
Change app.config.ts
with the cloudflare-module
settings to deploy to Cloudflare Workers.
app.config.ts
import { defineConfig } from '@tanstack/start/config';
import tsConfigPaths from 'vite-tsconfig-paths';
import { cloudflare } from 'unenv';
import nitroCloudflareBindings from 'nitro-cloudflare-dev';
export default defineConfig({
server: {
preset: 'cloudflare-module',
unenv: cloudflare,
modules: [nitroCloudflareBindings],
},
vite: {
plugins: [
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
],
},
});
create a wrangler.jsonc
file.
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "YOUR-WORKER-NAME",
"main": ".output/server/index.mjs",
"compatibility_date": "2025-04-01",
"compatibility_flags": ["nodejs_compat"],
"assets": {
"directory": ".output/public",
},
"observability": {
"enabled": true,
},
}
go to posts -> select a post -> refresh -> it crashes
Additional information
No response
👨👧👦 Contributing
- 🙋♂️ Yes, I'd be down to file a PR fixing this bug!