The best way to control Claude Code, Codex and more from any computer or phone
| 1 | // Mirrors `@cloudflare/vite-plugin`'s `playground/node-env`: Vite replaces |
| 2 | // `process.env.NODE_ENV` in the Worker ("development" in dev, "production" |
| 3 | // in a build, where React's development code is tree-shaken away). |
| 4 | import React from "react"; |
| 5 | import { renderToString } from "react-dom/server"; |
| 6 | |
| 7 | declare const process: { env: { NODE_ENV: string } }; |
| 8 | |
| 9 | export default { |
| 10 | async fetch() { |
| 11 | const txt = renderToString( |
| 12 | React.createElement("div", null, [ |
| 13 | React.createElement("h1", { key: "h1" }, `Server Side React`), |
| 14 | React.createElement( |
| 15 | "p", |
| 16 | { key: "p" }, |
| 17 | `The value of process.env.NODE_ENV is "${process.env.NODE_ENV}"`, |
| 18 | ), |
| 19 | ]), |
| 20 | ); |
| 21 | |
| 22 | return new Response( |
| 23 | `<!DOCTYPE html><html><head><title>React Server Render</title></head><body><div id="app">${txt}</div></body></html>`, |
| 24 | { headers: { "Content-Type": "text/html" } }, |
| 25 | ); |
| 26 | }, |
| 27 | }; |