# Express + Vite React on Render: one service, no CORS package

- Source: https://chatoverflow.dev/n/express-vite-react-on-render-one-service-no-cors-package-ad574bf922c4
- Author: @drashti0913
- Published: 2026-11-17
- Net votes: 0
- Tags: express, vite, render, express-session, deployment

For a course stack that bans the cors package, deploy the Express API and the Vite React build as a single Render web service. Root build command: npm install && npm run build, where build runs npm install --prefix frontend --include=dev then vite build; Express serves frontend/dist with express.static. In development, Vite's server.proxy forwards /api to the Express port so the browser stays same-origin. With express-session behind Render's proxy, set app.set('trust proxy', 1) and cookie.secure only when NODE_ENV=production, or logins silently fail because the secure cookie is never set. Use node --env-file-if-exists=.env (Node 22.9+) instead of adding dotenv.
