By default, your app might generate links like:
- β
http://localhost:3000?invite=abc123 - β Email invites pointing to localhost
- β CORS errors in production
Set these 2 environment variables in Render:
SERVER_URL=https://your-app-name.onrender.com
CLIENT_URL=https://your-app-name.onrender.comAfter deploying, Render gives you a URL like:
https://nego-messaging.onrender.com
Copy this URL!
Go to your Render service:
- Click "Environment" tab
- Click "Add Environment Variable"
- Add:
- Key:
SERVER_URL - Value:
https://your-app-name.onrender.com(your actual URL)
- Key:
- Click "Add Environment Variable" again
- Add:
- Key:
CLIENT_URL - Value:
https://your-app-name.onrender.com(same URL)
- Key:
- Click "Save Changes"
- Render will automatically redeploy (~2-3 minutes)
- Watch the logs to confirm success
β Create a room and copy invite link:
Good: https://your-app.onrender.com?invite=abc123
Bad: http://localhost:3000?invite=abc123
β Check browser console (F12):
Good: WebSocket connected to wss://your-app.onrender.com
Bad: WebSocket failed to connect to ws://localhost:3000
β Send invite email (if configured):
- Link should point to your Render URL, not localhost
| Feature | Before | After |
|---|---|---|
| Room invites | localhost:3000?invite=... |
your-app.onrender.com?invite=... |
| Email links | Broken localhost links | Working production links |
| SMS links | Broken localhost links | Working production links |
| CORS | May fail | Works properly |
| WebSocket | May connect to localhost | Connects to production |
| Widget SDK | May fail | Works properly |
If you add a custom domain (e.g., app.yourcompany.com):
- Add domain in Render (Settings β Custom Domains)
- Update both variables:
SERVER_URL=https://app.yourcompany.com CLIENT_URL=https://app.yourcompany.com
- Save and redeploy
Q: Why do I need both SERVER_URL and CLIENT_URL? A: They can be different if you have separate domains for API vs frontend. For most deployments, they're the same.
Q: Can I skip this step? A: The app will work, but:
- Invite links will be broken (localhost)
- Email/SMS features won't work properly
- Widget SDK may fail
- CORS might cause issues
Q: When should I set these? A: Right after your first deployment completes and you have a Render URL.
Q: Do I use http or https?
A: Always use https:// for Render deployments (SSL is automatic).
Q: What if I forget to do this? A: You can add them anytime. Just:
- Add the variables
- Save
- Render auto-redeploys
- All fixed! β
Once configured, your app will:
- β Generate correct production URLs
- β Send valid invite links via email/SMS
- β Handle CORS properly
- β Connect WebSockets correctly
- β Work with custom domains
No more localhost in production! π
Need more details? See PRODUCTION_URLS.md