How to Deploy a Full-Stack App to Render from WSL2 (Windows)

If you're building a web application using React (frontend) and Node.js/Express (backend) and you're working inside WSL2 on Windows, this guide is for you!
By the end of this blog, youβll have your full-stack app live on the internet using Render β a free hosting service that supports Node.js and static websites.
π Example Project Structure
Letβs say your project folder looks like this:
my-app/
βββ client/ # React frontend
βββ server/ # Express backend
βββ shared/ # Shared code used by both client and server
βββ .git/ # Git initialized
βββ README.md
βοΈ Prerequisites
Your app works locally inside WSL2
You pushed your code to a GitHub repository
You have:
β GitHub account
β Render account
β Step 1: Set Up Your Backend (Node.js + Express)
1.1. Go to server/
folder and make sure:
Your package.json
has a start script:
"scripts": {
"start": "node index.js"
}
Replace index.js
with your actual file name (like app.js
or server.js
).
1.2. Use environment variable for the port:
In your Express app:
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
This helps Render assign a dynamic port when deployed.
1.3. Add a .env.example
file
Create a file like this (just for documentation):
DATABASE_URL=your_database_url_here
JWT_SECRET=your_jwt_secret_here
Never upload your real .env
β only .env.example
.
1.4. Handling the shared/
folder (important!)
If your server imports from shared/
like this:
const someUtil = require('../shared/someUtil');
Make sure when you deploy on Render:
You tell Render the root folder is
server
You include the
shared/
folder in your Git repo (same parent asserver/
)In your backend code, use relative paths like
../shared/...
β This works perfectly as long as your file paths are correct and your repo has all folders.
π Step 2: Deploy Backend to Render
Go to Render Dashboard
Click "New +" β Web Service
Connect your GitHub account and select your repo
Now fill the form:
Field | Value |
Name | my-backend |
Root Directory | server |
Runtime | Node |
Build Command | npm install |
Start Command | npm start |
Click "Advanced" β Add Environment Variables manually (from your
.env.example
)Hit "Create Web Service"
π It will deploy your backend and give you a public URL like:
https://my-backend.onrender.com
Keep this URL β your frontend will use it!
π¨ Step 3: Prepare Your React Frontend
Go to your client/
folder.
3.1. Add a .env.production
file
VITE_API_URL=https://my-backend.onrender.com
You can now access this in React like:
const api = import.meta.env.VITE_API_URL;
β
Works for Vite-based apps. For CRA (Create React App), use REACT_APP_API_URL
instead.
3.2. Add a build
script in client/package.json
(if not present)
"scripts": {
"build": "vite build"
}
Or if you're using CRA:
"scripts": {
"build": "react-scripts build"
}
3.3. Test your build locally (optional)
cd client
npm run build
Make sure the dist/
or build/
folder is created successfully.
π Step 4: Deploy Frontend to Render (as Static Site)
Fill the form:
Field | Value |
Name | my-fr onten d |
Root Directory | client |
Build Command | n pm run build |
Publish Directory | dis t (for Vite) or build (for CRA) |
Add
VITE_API_URL
orREACT_APP_API_URL
in the environment variables section.Click "Create Static Site"
Render will build and host your frontend at a URL like:
https://my-frontend.onrender.com
π Step 5: Enable CORS on Backend
To let your frontend access the backend:
npm install cors
Then in server/index.js
:
const cors = require("cors");
app.use(cors({
origin: "https://my-frontend.onrender.com",
credentials: true,
}));
π Step 6: Test Everything
Open your frontend URL
Try submitting a form or logging in
Check the browser console (Dev Tools β Network tab) to make sure API requests are working
Recap: What We Did
β
Deployed a full-stack app (React + Node.js) using Render
β
Used .env.production
to connect frontend with backend
β
Configured CORS for safe communication
β
Handled shared code between client and server
β
Did all this from WSL2 on Windows
π‘ Bonus Tips
Add a custom domain to your frontend (Render allows free domains!)
Monitor logs in Render β Go to your service β Logs
Keep your
.env
secrets safe (never upload them to GitHub)
π Need Help?
If you're stuck or confused, just comment below or reach out. Iβll help you debug it!
Subscribe to my newsletter
Read articles from Shruti Sharma directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
