Tanstack Start + env: Redirected configurations cannot include environments

Hello everyone,
I have been trying to implement environments in my current project running Tanstack Start.
Deployments were working smoothly until I added deployments and I started getting build errors in the cloudflare CD.
12:19:12.983    Using redirected Wrangler configuration.
12:19:12.983     - Configuration being used: "server/wrangler.json"
12:19:12.983     - Original user's configuration: "../wrangler.jsonc"
12:19:12.983     - Deploy configuration file: "../.wrangler/deploy/config.json"
12:19:12.986    
12:19:13.030    ✘ [ERROR] Processing server/wrangler.json configuration:
12:19:13.030    
12:19:13.030        - Redirected configurations cannot include environments but the following have been found:
12:19:13.030              - development
12:19:13.030              - production
12:19:13.030      
12:19:13.030      
12:19:13.030          Such configurations are generated by tools, meaning that one of the tools
12:19:13.030          your application is using is generating the incorrect configuration.
12:19:13.030          Report this issue to the tool's author so that this can be fixed there.


Current vite.config.ts:
import { defineConfig } from 'vite';
import tailwindcss from '@tailwindcss/vite';
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
import tsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
  plugins: [
    tsConfigPaths({
      projects: ['./tsconfig.json'],
    }),
    tailwindcss(),
    tanstackStart({
      target: 'cloudflare-module', // Key configuration for Cloudflare compatibility
      tsr: {
        srcDirectory: 'src/ui',
      },
    }),
  ],
});


I followed the directions to handle environments but with no effect:
1. Created a new .env.development containing CLOUDFLARE_ENV=development and .env.production containing CLOUDFLARE_ENV=production
2. Changed the build script to vite build --mode development
3. Changed the deployment script to npx wrangler --cwd .output deploy

But so far I can't find anything more to fix this issue.
Does anyone have any idea? ❤️
Was this page helpful?