From 9ae820d76be32adbe1452d3e0e94e522e757afe1 Mon Sep 17 00:00:00 2001 From: ANKUR THENUA Date: Sat, 18 Jul 2026 20:43:04 +0530 Subject: [PATCH] Add deployment guide for Render (server + client + CORS fix) --- DEPLOYMENT.md | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 DEPLOYMENT.md diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md new file mode 100644 index 0000000..ee250fd --- /dev/null +++ b/DEPLOYMENT.md @@ -0,0 +1,80 @@ +\# Deploying PyBe to Render + + + +This guide documents the steps to deploy the PyBe app (server + client) to Render.com for free, based on hands-on testing. + + + +\## Backend (Server) Deployment + + + +1\. On Render, create a \*\*New Web Service\*\* and connect your GitHub repository. + +2\. Set the following: + + - \*\*Root Directory:\*\* `server` + + - \*\*Build Command:\*\* `npm install` + + - \*\*Start Command:\*\* `node src/index.js` + + - \*\*Instance Type:\*\* Free + +3\. Deploy. Note the live URL Render gives you (e.g. `https://your-app.onrender.com`). + + + +\## Frontend (Client) Deployment + + + +1\. On Render, create a \*\*New Static Site\*\* and connect the same repository. + +2\. Set the following: + + - \*\*Root Directory:\*\* `client` + + - \*\*Build Command:\*\* `npm install; npm run build` + + - \*\*Publish Directory:\*\* `dist` + +3\. Add an environment variable so the client knows where the backend lives: + + - \*\*Key:\*\* `VITE\_API\_URL` + + - \*\*Value:\*\* `https://your-backend-url.onrender.com/api` + +4\. Deploy. + + + +\## Fixing CORS Issues + + + +If the deployed client shows `Failed to fetch` or CORS errors in the browser console, it usually means the backend's allowed origin doesn't match the deployed frontend URL. + + + +Fix: On the backend service in Render, go to \*\*Environment\*\* and add: + + - \*\*Key:\*\* `CLIENT\_ORIGIN` + + - \*\*Value:\*\* your deployed frontend URL (e.g. `https://your-frontend.onrender.com`) + + + +Save changes — Render will automatically redeploy the backend with the new setting. + + + +\## Notes + + + +\- Render's free tier spins down services after inactivity, so the first request after idling can take 30-50 seconds to respond. + +\- Always redeploy the backend after changing environment variables for the change to take effect. +