You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If opted for separate backend/frontend setup an option to choose to have frontend being served via static bundle files instead of running two separate servers for frontend and backend
The text was updated successfully, but these errors were encountered:
So given this scaffold -> pnpm create better-t-stack@latest my-better-t-app --yes --backend express --runtime node --api orpc --database none --orm none --no-auth --package-manager pnpm --no-git --addons biome
You’ll get a project with a separate backend (Express) and frontend (React), set up to use CORS by default. This is one valid approach.
Option 1: With CORS
The frontend and backend run on separate servers with CORS enabled.
This setup is useful if you want to deploy your React app to a CDN (like Vercel, Netlify, or S3) and your backend to a different server.
The frontend makes API requests directly to the backend, and CORS handles cross-origin requests.
Option 2: Without CORS (Proxy Setup)
You remove the CORS middleware from your Express backend.
During development, you set up a proxy in the Vite dev server so API requests go through the frontend server to the backend.
In production, you build the React app and serve the static files directly from the Express backend. Now, everything runs from a single server and origin, so CORS isn’t needed.
Summary:
Option 1 (CORS): Deploy frontend and backend separately (e.g., React on CDN, backend elsewhere).
Option 2 (Proxy, no CORS): Deploy only the backend; it serves both the API and the built frontend as static files. The whole app runs as one service.
I think this would be a great addition to options to choose from:
The text was updated successfully, but these errors were encountered: