#Prerender fails setting `--env staging` since `dist/server/wrangler.json` is flat

2 messages · Page 1 of 1 (latest)

left mirage
#

I am trying to bun run build my application, which uses pre-rendering. When I run bun run dev (which sets CLOUDFLARE_ENV=local), everything works fine, but when I bun run build:staging (which sets CLOUDFLARE_ENV=staging), it fails at the prerender step when it fails to spin up a preview. I get this error:

▲ [WARNING] Processing dist/server/wrangler.json configuration:

    - No environment found in configuration with name "staging".
      Before using `--env=staging` there should be an equivalent environment section in the
  configuration.

      Consider adding an environment configuration section to the wrangler.json file:
      ```
      [env.staging]
      ```



error during build:
Error: Failed to start the Vite preview server for prerendering
    at startPreviewServer (file:///Users/william/Mirascope/GitHub/mirascope/cloud/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:195:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async prerender (file:///Users/william/Mirascope/GitHub/mirascope/cloud/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:42:25)
    at async postServerBuild (file:///Users/william/Mirascope/GitHub/mirascope/cloud/node_modules/@tanstack/start-plugin-core/dist/esm/post-server-build.js:38:5)
    at async BasicMinimalPluginContext.handler (file:///Users/william/Mirascope/GitHub/mirascope/cloud/node_modules/@tanstack/start-plugin-core/dist/esm/plugin.js:285:11)
    at async Object.buildApp (file:///Users/william/Mirascope/GitHub/mirascope/cloud/node_modules/vite/dist/node/chunks/config.js:33893:5)
    at async CAC.<anonymous> (file:///Users/william/Mirascope/GitHub/mirascope/cloud/node_modules/vite/dist/node/cli.js:629:3)
error: script "build" exited with code 1

Any ideas on how I can get the preview server to run properly?

thorny quest
#

so do you have that staging section in your wrangler config?