Fix CORS Error on Render.com
Updated April 2026
Reading this article? Verify your fix in real-time. Test your Render.com CORS config → CORSFixer
Render.com is a hosting platform — CORS headers are your application's responsibility, not Render's. The fix is in your server code, not Render's dashboard.
The approach
Render runs your Docker container or build output. CORS headers must be set by your application. Apply the standard fix for your framework:
| Framework | Fix |
|---|---|
| Express / Node.js | Express CORS guide → |
| FastAPI / Python | FastAPI CORS guide → |
| Django | Django CORS guide → |
| Flask | Flask CORS guide → |
| Go | Go CORS guide → |
| Ruby on Rails | Rails CORS guide → |
| Static site with Nginx | See Nginx config below |
Render with Nginx (static sites or Docker)
# nginx.conf
server { listen 10000; # Render uses port 10000 by default location / { root /usr/share/nginx/html; index index.html; # CORS for API calls if ($request_method = OPTIONS) { add_header Access-Control-Allow-Origin "https://yourapp.com"; add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"; add_header Access-Control-Allow-Headers "Authorization, Content-Type"; add_header Content-Length 0; return 204; } add_header Access-Control-Allow-Origin "https://yourapp.com" always; }
}
Render environment variables for origin config
# In Render dashboard — Environment tab
CORS_ORIGIN=https://yourapp.com
# In your Express app
const corsOrigin = process.env.CORS_ORIGIN || "http://localhost:3000";
app.use(cors({ origin: corsOrigin }));
Common Render-specific issue — wrong port
# Render requires your app to listen on the PORT env variable const PORT = process.env.PORT || 3000; app.listen(PORT);
If your app is not listening on the correct port, Render cannot route requests to it — which appears as a network error, not a CORS error. Check Render logs first.
Render Web Service + separate frontend
If your frontend is on Vercel or Netlify and your backend is on Render, it is a cross-origin setup. Set the backend CORS_ORIGIN env variable to your Vercel/Netlify frontend URL in the Render dashboard.