The Reality of MERN Production Deployments

So you've built an amazing MERN app that works perfectly on localhost. Time to deploy, right?

Wrong. Your development environment is a lying piece of shit. Everything works perfectly in your cozy local setup with 32GB RAM and no network latency, then you deploy and suddenly everything breaks in ways that shouldn't be physically possible.

What Actually Happens When You Go Live

I've been doing this for 8 years, and I've seen the same pattern repeat itself. Developer builds amazing MERN app, works perfectly on localhost, deploys to production, then spends the next three days dealing with the same common deployment issues that hit everyone:

Accept this now: production will break. Your job is building systems that don't completely explode when (not if) everything goes wrong at the worst possible moment.

Docker: Your Best Friend and Worst Enemy

Docker Logo

Docker solves the "works on my machine" problem, but creates a dozen new problems. Here's what I learned the hard way:

Multi-stage builds are mandatory

Single-stage Docker builds for MERN apps will create 2GB+ images. This is stupid and slow. Multi-stage builds cut that down to 100-300MB:

## Frontend build - this will be huge temporarily
FROM node:18-alpine AS react-builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build

## Production - just the static files
FROM nginx:alpine
COPY --from=react-builder /app/build /usr/share/nginx/html
## This nginx config is critical - default won't work with React Router
COPY nginx.prod.conf /etc/nginx/nginx.conf

The shit that always breaks:

  • Node version mismatches: Development uses Node 24, production uses Node 22.8.0, something breaks. Pin exact versions: FROM node:22.8.0-alpine (Node 22 LTS until late 2025)
  • Memory limits: React builds eat RAM. Set NODE_OPTIONS="--max-old-space-size=4096" or watch your CI fail
  • Alpine Linux differences: Some npm packages don't work on Alpine. Switch to node:22-slim if you hit weird errors
  • File permissions: Your containers run as root locally but not in production. This bites everyone eventually

MongoDB: The Database That Lies to You

MongoDB Logo

MongoDB says it's web-scale. MongoDB lies. Here's what actually happens:

Connection pool exhaustion

Default Mongoose settings will fuck you over. Use this or suffer:

mongoose.connect(process.env.MONGO_URI, {
  maxPoolSize: 10,
  serverSelectionTimeoutMS: 5000,
  socketTimeoutMS: 45000,
  family: 4 // Force IPv4, IPv6 causes random timeouts
});

Memory usage explosion

MongoDB will happily use all your RAM for caching. In containers, this kills other processes. Set `wiredTigerCacheSizeGB` explicitly.

Real incident: August 2025, our MongoDB container hit the 512MB limit and started OOMKilling every 15 minutes. Took 3 hours to figure out the default cache size was 50% of system memory, not container memory. Solution: cacheSizeGB: 0.25 for a 512MB container.

Index disasters

Your 100-record dev database doesn't need indexes. Your production database with 100k+ records will crawl without them. Add indexes BEFORE you deploy, not after users complain about slow queries.

CI/CD: Automation That Sometimes Works

CI/CD Pipeline

GitHub Actions is decent, but every MERN pipeline will hit these issues:

Random timeouts and failures

GitHub's runners sometimes just fail. Your pipeline needs retry logic:

- name: Install dependencies
  run: npm ci
  timeout-minutes: 10
  # This will save you hours of confusion

Environment variable hell

Never put secrets in your code. Never put secrets in your Docker images. Use GitHub Secrets, but test them first - case sensitivity will bite you.

Deployment lag

Your CI says "deployment successful" but users still see the old version. CDN caches, browser caches, and load balancer health checks all add delay. Plan for 2-5 minutes between deployment and live changes.

The Monitoring You Actually Need

Forget APM tools for now. Start with basics:

  • Health check endpoints: /health that checks database connectivity
  • Error logging: Winston with structured logs, not console.log
  • Basic metrics: Response times, error rates, memory usage
  • Alerts: When error rate > 5% or response time > 2 seconds

New Relic and DataDog are nice but overkill until you have real traffic. Start simple, then upgrade when you're actually making money.

What Works in Practice

Express.js Logo

After breaking production dozens of times, here's my current setup (updated for September 2025):

  • Docker Compose for local development that mirrors production
  • GitHub Actions with proper retry logic and timeout handling
  • AWS ECS because it's simpler than Kubernetes for MERN apps
  • MongoDB Atlas because managing MongoDB yourself sucks
  • CloudFront for React static assets
  • Sentry for error tracking (it's cheap and catches frontend errors)

This setup handles 10k-100k users/month reliably. Scale up from here, don't start with Kubernetes unless you hate yourself.

Alright, you get the picture - everything's fucked. But here's the thing: once you know what breaks, you can build around it. Next section shows you exactly how to set this up so you're not the one getting paged at 3am.

Step-by-Step: Deploy MERN Apps That Don't Suck

Alright, let's actually build this thing.

Here are the exact steps I use, including all the gotchas that aren't mentioned in the official docs because the people who write documentation apparently never deploy to production.

Step 1: Fix Your Repository Structure

First, stop putting everything in the root folder like an animal.

Here's the project structure that actually works:

your-mern-app/
├── frontend/
│   ├── src/
│   ├── public/
│   ├── Dockerfile
│   ├── nginx.conf
│   └── package.json
├── backend/
│   ├── src/
│   ├── Dockerfile
│   └── package.json
├── docker-compose.yml
├── .github/workflows/
│   └── deploy.yml
└── .env.example

The environment variable nightmare

Create `.env.example` with all the variables you need, but NEVER commit actual values:

## Backend
NODE_ENV=production
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_here
PORT=5000

## Frontend  
REACT_APP_API_URL=https://api.yourdomain.com
REACT_APP_SENTRY_DSN=your_sentry_dsn

Pro tip I learned the hard way:

Use different variable names for different environments. MONGO_URI_PROD, MONGO_URI_DEV, etc. December 2024, I accidentally wiped our entire staging database because I was running prod credentials locally. Spent a weekend recreating test data. Don't be me.

Step 2: Docker That Actually Works

Docker Multi-stage Build

Frontend Dockerfile (the one that won't break)

## Build stage 
- this gets deleted after build
FROM node:
22.8.0-alpine AS builder
WORKDIR /app

## Copy package files first for better [Docker layer caching](https://docs.docker.com/build/cache/)
COPY package*.json ./
RUN npm ci --only=production

## Copy source and build
COPY . .

RUN npm run build

## Production stage 
- lightweight nginx
FROM nginx:
1.27-alpine

## Custom nginx config is MANDATORY for [React Router](https://create-react-app.dev/docs/deployment/#serving-apps-with-client-side-routing)
COPY nginx.conf /etc/nginx/nginx.conf

## Copy built React app
COPY --from=builder /app/build /usr/share/nginx/html

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

The nginx config that saves your React routing

React Logo

Create frontend/nginx.conf:

events {
    worker_connections 1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    
    server {
        listen 80;
        server_name localhost;
        root /usr/share/nginx/html;
        index index.html;
        
        # This is the magic line for React Router
        location / {
            try_files $uri $uri/ /index.html;
        }
        
        # Cache static assets
        location /static/ {
            expires 1y;
            add_header Cache-Control "public, immutable";
        }
    }
}

Backend Dockerfile (non-root user, because security)

Node.js Logo

FROM node:
22.8.0-alpine

## Create app directory and [non-root user](https://docs.docker.com/develop/best-practices/dockerfile_best_practices/#user) for security
WORKDIR /app
RUN addgroup -g 1001 -S nodejs && adduser -S nodeuser -u 1001

## Copy package files
COPY package*.json ./
RUN npm ci --only=production && npm cache clean --force

## Copy source code
COPY --chown=nodeuser:nodejs . .

## Switch to non-root user
USER nodeuser

EXPOSE 5000

## Use node instead of npm start ([npm doesn't forward signals properly](https://github.com/nodejs/docker-node/blob/main/docs/Best

Practices.md#handling-kernel-signals))
CMD ["node", "src/server.js"]

Step 3:

Local Development That Mirrors Production

Docker Compose configuration that won't lie to you

version: '3.8'

services:
  frontend:
    build: ./frontend
    ports:

- "3000:80"
    depends_on:

- backend
    environment:

- REACT_APP_API_URL=http://localhost:5000

  backend:
    build: ./backend
    ports:

- "5000:5000"
    depends_on:

- mongodb
    environment:

- NODE_ENV=development
      
- MONGO_URI=mongodb://mongodb:27017/yourapp
      
- JWT_SECRET=dev-secret-change-in-production
    volumes:

- ./backend:/app
      
- /app/node_modules

  mongodb:
    image: mongo:
6.0
    ports:

- "27017:27017"
    volumes:

- mongo_data:/data/db
    environment:

      MONGO_INITDB_DATABASE: yourapp

volumes:
  mongo_data:

Test it: `docker-compose up --build`.

If it doesn't work, check:

Port conflicts (something else using 3000, 5000, or 27017) 2. Memory issues (Docker Desktop needs 4GB+ for MERN apps) 3. File permissions (Windows/WSL problems are common)

Step 4: GitHub Actions That Don't Randomly Fail

The GitHub Actions workflow I actually use

.github/workflows/deploy.yml:

name:

 Deploy MERN App

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:

  NODE_VERSION: '22.8.0'  # Pin exact version (LTS until late 2025)

jobs:
  test:
    runs-on: ubuntu-latest
    
    steps:

- uses: actions/checkout@v4
    
    
- name:

 Setup Node.js
      uses: actions/setup-node@v4
      with:
        node-version: ${{ env.

NODE_VERSION }}
        cache: 'npm'
        cache-dependency-path: |
          frontend/package-lock.json
          backend/package-lock.json
    
    # Frontend tests
    
- name:

 Install frontend dependencies
      run: cd frontend && npm ci
      
    
- name:

 Run frontend tests
      run: cd frontend && npm test -- --coverage --watchAll=false
      
    # Backend tests  
    
- name:

 Install backend dependencies
      run: cd backend && npm ci
      
    
- name:

 Run backend tests
      run: cd backend && npm test
      
    # Security audit (this will fail if vulnerabilities found)
    
- name:

 Audit dependencies
      run: |
        cd frontend && npm audit --audit-level high
        cd backend && npm audit --audit-level high

  deploy:
    if: github.ref == 'refs/heads/main'
    needs: test
    runs-on: ubuntu-latest
    
    steps:

- uses: actions/checkout@v4
    
    # Build and push Docker images
    
- name:

 Build images
      run: |
        docker build -t your-registry/frontend:${{ github.sha }} ./frontend
        docker build -t your-registry/backend:${{ github.sha }} ./backend
        
    # Deploy to your hosting platform
    # (Replace with your deployment method)
    
- name:

 Deploy to production
      run: echo "Deploy your containers here"

Common GitHub Actions gotchas:

  • Timeouts:

Add timeout-minutes: 15 to each step.

GitHub runners randomly die after 10 minutes sometimes

  • Secrets: Case-sensitive, test them in a small workflow first.

Spent 2 hours debugging DATABASE_URL vs DATABASE_url in July 2025

  • Caching: npm cache sometimes corrupts, add cache key with date if needed
  • Memory limits:

React builds can hit 2GB memory limit, use NODE_OPTIONS: '--max-old-space-size=4096'

  • Runner inconsistency: ubuntu-latest switched from Ubuntu 20 to 22 in June 2025, breaking Python 2.7 dependencies

Step 5:

Production Deployment (AWS ECS Example)

Why I use [ECS](https://aws.amazon.com/ecs/) instead of [Kubernetes](https://kubernetes.io/)

AWS ECS Architecture

Kubernetes is overkill for most MERN apps. ECS is simpler:

Less configuration hell 2. Better AWS integration 3. Managed control plane 4. Cheaper for small apps

Basic ECS setup commands:

## Create cluster
aws ecs create-cluster --cluster-name mern-production

## Create task definition (simplified)
aws ecs register-task-definition \
  --family mern-app \
  --requires-compatibilities FARGATE \
  --network-mode awsvpc \
  --cpu 256 --memory 512 \
  --container-definitions file://task-definition.json

## Create service
aws ecs create-service \
  --cluster mern-production \
  --service-name mern-service \
  --task-definition mern-app:1 \
  --desired-count 2

Step 6:

Monitoring That Actually Helps

AWS Logo

Start simple with health checks:

// backend/src/routes/health.js
app.get('/health', async (req, res) => {
  try {
    // Check database connection
    await mongoose.connection.db.admin().ping();
    
    res.json({
      status: 'healthy',
      timestamp: new Date().to

ISOString(),
      uptime: process.uptime(),
      memory: process.memoryUsage()
    });
  } catch (error) {
    res.status(503).json({
      status: 'unhealthy',
      error: error.message
    });
  }
});

Add Sentry for error tracking:

npm install @sentry/react @sentry/node

Frontend:

import * as Sentry from \"@sentry/react\";

Sentry.init({
  dsn: process.env.

REACT_APP_SENTRY_DSN,
  environment: process.env.

NODE_ENV
});

The Deployment Checklist I Actually Use

Before going live:

  • Environment variables set correctly
  • Database indexes created
  • SSL certificate configured
  • Health checks responding
  • Error tracking configured
  • Backup strategy tested
  • Rollback plan documented
  • Domain DNS pointing to load balancer
  • CDN cache invalidation working

This setup handles most MERN apps up to significant scale.

Once you're processing millions of requests, then worry about Kubernetes, microservices, and other complex shit.

So where the hell should you actually deploy this thing? Platform comparison coming up shows what each option actually costs and where they'll screw you over

  • because "it depends" is useless when your boss wants it live by Friday.

Platform Comparison: What Actually Works vs. What Looks Good on Paper

Category

Tool/Platform

Pros/What Works

Cons/What Sucks

Details/Reality

Cost

When to Use

Cloud Providers

AWS

ECS, Lambda, DocumentDB, CloudFront

The console UI looks like it was designed in 2008, billing surprises that made me question my life choices, complexity overload

Powerful but you'll spend weeks learning it. Budget $200+/month minimum for production. ECS is solid for containers, avoid Elastic Beanstalk like the fucking plague

  • it will fail in mysterious ways.

Budget $200+/month minimum for production.

You have AWS experience or enterprise budget

Cloud Providers

Google Cloud

Cloud Run, Firebase, simple pricing

Smaller community, less third-party tooling

Easier than AWS but less mature. Cloud Run is perfect for MERN apps

  • scales to zero, handles traffic spikes well.

simple pricing

You want simplicity over power

Cloud Providers

DigitalOcean

App Platform, reasonable pricing, good docs

Limited services, no advanced features

Great for startups. App Platform deploys MERN apps with minimal config. Runs my side projects for $25/month.

Runs my side projects for $25/month.

You're bootstrapping or building simple apps

Cloud Providers

Vercel + MongoDB Atlas

Zero config deployments, global CDN, serverless functions

Backend limitations, vendor lock-in, expensive at scale

Perfect for demos and MVPs. Hits pricing wall around 100k users/month.

expensive at scale

Prototype or frontend-heavy apps

CI/CD

GitHub Actions

Free tier covers most projects, great ecosystem, works everywhere

Can be slow, occasional outages, limited Windows support

This is my default. 2000 minutes/month free goes further than you think.

2000 minutes/month free

Default choice

CI/CD

GitLab CI/CD

Better than GitHub Actions for complex pipelines, free self-hosted runners

Smaller ecosystem, GitLab platform feels clunky

Good if you're already on GitLab. Otherwise, stick with GitHub Actions.

free self-hosted runners

If you're already on GitLab

CI/CD

Jenkins

Ultimate flexibility, enterprise features, plugins for everything

Maintenance nightmare, security headaches, Java-based horror

Only use if required by corporate policy. Modern alternatives are better.

Only use if required by corporate policy

CI/CD

CircleCI

Fast builds, good Docker support, decent free tier

Pricing gets expensive, less popular than GitHub Actions

Solid but unnecessary if you're on GitHub already.

Pricing gets expensive, decent free tier

(implied if not on GitHub)

Monitoring

Sentry

Catches frontend and backend errors, cheap, easy setup

Not full APM, limited performance monitoring

Free for 5k errors/month, then $26/month

You're not making money yet

Monitoring

DataDog

Everything in one dashboard, great alerting, integrates with everything

Expensive ($15/host/month adds up), overwhelming for small teams

Expensive ($15/host/month)

You have budget and dedicated DevOps

Monitoring

New Relic

Solid APM, decent free tier, good Node.js support

UI is confusing, pricing model is weird

decent free tier, pricing model is weird

DataDog is too expensive but you need APM

Monitoring

CloudWatch (AWS Only)

Comes with AWS services, cheap

Terrible UI, limited features, AWS lock-in

cheap

You're already deep in AWS and don't want another bill

Container Orchestration

Docker Compose

Local development, single server deployments, learning

High availability, auto-scaling, load balancing

Perfect starting point. Most MERN apps don't outgrow this immediately.

Local development, single server deployments, learning

Container Orchestration

AWS ECS

Managed control plane, AWS integration, reasonable complexity

AWS lock-in, confusing task definitions, networking complexity

Sweet spot for most MERN apps. Less complex than Kubernetes, more scalable than Docker Compose.

Most MERN apps

Container Orchestration

Kubernetes

Ultimate flexibility, multi-cloud, huge ecosystem

Steep learning curve, over-engineering, operational overhead

Only use if you have multiple services, dedicated DevOps, or masochistic tendencies.

Multiple services, dedicated DevOps, or masochistic tendencies

Container Orchestration

AWS Fargate

Zero server management, pay-per-task pricing

More expensive, limited control, cold starts

Great for sporadic workloads. Bad for high-traffic apps due to cost.

More expensive, pay-per-task pricing

Sporadic workloads

Database

MongoDB Atlas

Zero ops, global clusters, automatic scaling, MongoDB expertise

Vendor lock-in, can get expensive, networking complexity

This is what most MERN apps should use. Self-hosting MongoDB sucks.

Free tier → $9/month → $57/month → $$$$

Most MERN apps

Database

AWS DocumentDB

AWS-native, VPC integration, managed backups

Not real MongoDB (missing features), AWS lock-in, cold storage costs

Use if you're AWS-heavy and don't need latest MongoDB features.

cold storage costs

If you're AWS-heavy and don't need latest MongoDB features

Database

Self-hosted MongoDB

Full control, potentially cheaper, no vendor lock-in

Backup disasters, security nightmares, operational overhead

Don't do this unless you have a dedicated DBA and strong operational practices.

potentially cheaper

Only if you have a dedicated DBA and strong operational practices

FAQ: Real Problems, Real Solutions

Q

Why does my Docker container keep restarting?

A

Check these in order:

  1. Out of memory: Your React build probably ate all 512MB. Bump to 1GB minimum
  2. Port conflicts: Something else is using your port. Change to 3001 or kill the other process
  3. Failed health checks: Your /health endpoint isn't responding. Fix it or disable health checks temporarily
  4. Environment variables missing: Check docker logs container-name for errors about missing vars

Copy this to debug: docker logs --tail 50 -f your-container-name

Q

My MongoDB connection keeps timing out in production but works locally

A

MongoDB Atlas fucking loves to timeout. Here's what actually fixes it:

// This works in production
mongoose.connect(uri, {
  maxPoolSize: 10,
  serverSelectionTimeoutMS: 5000,
  socketTimeoutMS: 45000,
  family: 4, // Force IPv4 - IPv6 causes random timeouts
  bufferCommands: false // Fail fast instead of hanging
});

Also check if Atlas whitelisted your server IP. This bites everyone.

Q

GitHub Actions is failing randomly with "Error: Process completed with exit code 1"

A

The real causes (not what the error says):

  • npm ci failed: Delete package-lock.json, run npm install, commit the new lock file
  • Memory limit: Add NODE_OPTIONS: '--max-old-space-size=4096' to your workflow
  • Flaky tests: Add retry logic or --maxWorkers=2 to reduce parallelism
  • GitHub's runners are fucked: Retry the workflow. Seriously.
Q

React app shows blank page in production

A

Check these immediately:

  1. Build path issues: Look for 404s in browser console for CSS/JS files
  2. Router issues: nginx needs try_files $uri $uri/ /index.html; for React Router
  3. Environment variables: REACT_APP_ prefix required for custom vars
  4. CORS: API calls failing because backend doesn't allow your domain

Quick fix: curl -I your-frontend-url and check for 200 status

Q

My Docker images are 2GB+, builds take forever

A

Multi-stage builds. No exceptions:

FROM node:22.8.0-alpine AS builder
## Build shit here

FROM node:22.8.0-alpine AS production
## Copy only what you need

Also add .dockerignore:

node_modules
.git
*.md
.env*
Q

Docker build fails with "no space left on device"

A

Run this nuclear option:

docker system prune -a --volumes

Then set up proper cleanup:

## Add to crontab
0 2 * * * docker system prune -f
Q

Containers work locally but fail in production

A

Platform differences. Pin your versions:

Latest nightmare: September 2025, Docker Hub switched Node.js 22-alpine from Alpine 3.18 to 3.20 overnight. Broke our native dependencies (sharp, bcrypt, etc.). Spent 6 hours figuring out we needed to rebuild with npm rebuild or pin to the exact digest. This is why I have trust issues with container registries.

FROM node:22.8.0-alpine  # Not just "node:22"

Check architecture: docker buildx build --platform linux/amd64

Q

MongoDB query is slow/timing out in production

A

You need indexes. No seriously, add them:

// Find slow queries first
db.collection.createIndex({ email: 1 })
db.collection.createIndex({ created_at: -1 })
db.collection.createIndex({ user_id: 1, type: 1 }) // Compound for complex queries

Check what queries are slow:

// Enable profiling
db.setProfilingLevel(2, { slowms: 100 })
Q

Database running out of connections

A

Default Mongoose settings suck:

mongoose.connect(uri, {
  maxPoolSize: 10,    // Not 100
  minPoolSize: 2,
  maxIdleTimeMS: 30000
});

// Also close connections properly
process.on('SIGINT', () => {
  mongoose.connection.close(() => {
    process.exit(0);
  });
});
Q

GitHub Actions secrets not working

A

Case sensitivity will fuck you:

  • Secret name: API_KEY
  • Environment var: ${{ secrets.API_KEY }}

Test secrets first:

- name: Test secrets
  run: echo "Secret length:" ${#API_KEY}
  env:
    API_KEY: ${{ secrets.API_KEY }}
Q

Deployment says successful but users see old version

A

Cache hell. Check these:

  1. CDN cache: Invalidate CloudFront/CDN cache
  2. Browser cache: Versioned asset URLs help
  3. Load balancer health checks: New containers might not be ready
  4. DNS propagation: Wait 5-10 minutes

Force cache bust: Add ?v=${timestamp} to asset URLs

Q

Tests pass locally but fail in CI

A

Different environments. Common causes:

  • Timezone differences: Use UTC in tests
  • Race conditions: Increase timeouts, add wait-for-it scripts
  • File paths: Use path.join(), not hardcoded slashes
  • Memory limits: CI has less RAM than your laptop
Q

App is slow/users complaining

A

Check this order:

  1. Database queries: Enable MongoDB slow query log
  2. API response times: Add logging with response times
  3. Bundle size: Run npm run build --analyze
  4. Memory leaks: Monitor container memory usage over time

Quick wins:

  • Add database indexes
  • Enable gzip compression
  • Use React.memo() for expensive components
  • Add basic caching with Redis
Q

React app takes forever to load

A

Bundle size problems:

## Check what's in your bundle
npm install -g webpack-bundle-analyzer
npx webpack-bundle-analyzer build/static/js/*.js

Common fixes:

  • Remove unused dependencies
  • Lazy load routes with React.lazy()
  • Use dynamic imports for large libraries
  • Enable tree shaking
Q

Memory usage keeps growing (memory leaks)

A

For Node.js:

// Monitor memory
setInterval(() => {
  const memory = process.memoryUsage();
  console.log('Memory:', Math.round(memory.heapUsed / 1024 / 1024), 'MB');
}, 30000);

Common causes:

  • Event listeners not removed
  • Intervals not cleared
  • Large objects held in closure scope
  • Mongoose connections not closed
Q

SSL certificate issues

A

Let's Encrypt problems:

  1. Domain not pointing to server yet
  2. Firewall blocking port 80
  3. nginx not configured for ACME challenge

Quick check: curl -I http://yourdomain.com should work first

Q

Environment variables not working

A

Check these gotchas:

  • React: Must start with REACT_APP_
  • Docker: Use ARG for build-time, ENV for runtime
  • Quotes: API_URL=http://localhost not API_URL="http://localhost"
  • Spaces: No spaces around =
Q

CORS errors in production but not development

A

Your backend needs to allow your production domain:

app.use(cors({
  origin: [
    'http://localhost:3000',
    'https://yourdomain.com',
    'https://www.yourdomain.com'
  ]
}));

Most MERN production fires are configuration problems, not code bugs. When shit breaks: check logs first, then environment variables, then network connectivity. In that order. Don't overthink it.

Resources That Actually Help (Not Just Marketing Pages)

Related Tools & Recommendations

review
Similar content

Bun vs Node.js vs Deno: JavaScript Runtime Production Guide

Two years of runtime fuckery later, here's the truth nobody tells you

Bun
/review/bun-nodejs-deno-comparison/production-readiness-assessment
100%
tool
Similar content

MongoDB Atlas Enterprise Deployment: A Comprehensive Guide

Explore the comprehensive MongoDB Atlas Enterprise Deployment Guide. Learn why Atlas outperforms self-hosted MongoDB, its robust security features, and how to m

MongoDB Atlas
/tool/mongodb-atlas/enterprise-deployment
63%
integration
Similar content

Jenkins Docker Kubernetes CI/CD: Deploy Without Breaking Production

The Real Guide to CI/CD That Actually Works

Jenkins
/integration/jenkins-docker-kubernetes/enterprise-ci-cd-pipeline
61%
howto
Similar content

MongoDB to PostgreSQL Migration: The Complete Survival Guide

Four Months of Pain, 47k Lost Sessions, and What Actually Works

MongoDB
/howto/migrate-mongodb-to-postgresql/complete-migration-guide
44%
compare
Recommended

PostgreSQL vs MySQL vs MongoDB vs Cassandra - Which Database Will Ruin Your Weekend Less?

Skip the bullshit. Here's what breaks in production.

PostgreSQL
/compare/postgresql/mysql/mongodb/cassandra/comprehensive-database-comparison
42%
tool
Recommended

Google Kubernetes Engine (GKE) - Google's Managed Kubernetes (That Actually Works Most of the Time)

Google runs your Kubernetes clusters so you don't wake up to etcd corruption at 3am. Costs way more than DIY but beats losing your weekend to cluster disasters.

Google Kubernetes Engine (GKE)
/tool/google-kubernetes-engine/overview
40%
compare
Recommended

Framework Wars Survivor Guide: Next.js, Nuxt, SvelteKit, Remix vs Gatsby

18 months in Gatsby hell, 6 months testing everything else - here's what actually works for enterprise teams

Next.js
/compare/nextjs/nuxt/sveltekit/remix/gatsby/enterprise-team-scaling
39%
troubleshoot
Recommended

Fix Kubernetes Service Not Accessible - Stop the 503 Hell

Your pods show "Running" but users get connection refused? Welcome to Kubernetes networking hell.

Kubernetes
/troubleshoot/kubernetes-service-not-accessible/service-connectivity-troubleshooting
38%
troubleshoot
Recommended

Docker Won't Start on Windows 11? Here's How to Fix That Garbage

Stop the whale logo from spinning forever and actually get Docker working

Docker Desktop
/troubleshoot/docker-daemon-not-running-windows-11/daemon-startup-issues
33%
howto
Recommended

Stop Docker from Killing Your Containers at Random (Exit Code 137 Is Not Your Friend)

Three weeks into a project and Docker Desktop suddenly decides your container needs 16GB of RAM to run a basic Node.js app

Docker Desktop
/howto/setup-docker-development-environment/complete-development-setup
33%
news
Recommended

Docker Desktop's Stupidly Simple Container Escape Just Owned Everyone

integrates with Technology News Aggregation

Technology News Aggregation
/news/2025-08-26/docker-cve-security
33%
alternatives
Recommended

Redis Alternatives for High-Performance Applications

The landscape of in-memory databases has evolved dramatically beyond Redis

Redis
/alternatives/redis/performance-focused-alternatives
32%
compare
Recommended

Redis vs Memcached vs Hazelcast: Production Caching Decision Guide

Three caching solutions that tackle fundamentally different problems. Redis 8.2.1 delivers multi-structure data operations with memory complexity. Memcached 1.6

Redis
/compare/redis/memcached/hazelcast/comprehensive-comparison
32%
tool
Recommended

Redis - In-Memory Data Platform for Real-Time Applications

The world's fastest in-memory database, providing cloud and on-premises solutions for caching, vector search, and NoSQL databases that seamlessly fit into any t

Redis
/tool/redis/overview
32%
integration
Similar content

MongoDB Express Mongoose Production: Deployment & Troubleshooting

Deploy Without Breaking Everything (Again)

MongoDB
/integration/mongodb-express-mongoose/production-deployment-guide
31%
alternatives
Recommended

Your MongoDB Atlas Bill Just Doubled Overnight. Again.

powers MongoDB Atlas

MongoDB Atlas
/alternatives/mongodb-atlas/migration-focused-alternatives
29%
howto
Recommended

Install Node.js with NVM on Mac M1/M2/M3 - Because Life's Too Short for Version Hell

My M1 Mac setup broke at 2am before a deployment. Here's how I fixed it so you don't have to suffer.

Node Version Manager (NVM)
/howto/install-nodejs-nvm-mac-m1/complete-installation-guide
27%
integration
Recommended

Claude API Code Execution Integration - Advanced Tools Guide

Build production-ready applications with Claude's code execution and file processing tools

Claude API
/integration/claude-api-nodejs-express/advanced-tools-integration
27%
compare
Recommended

Python vs JavaScript vs Go vs Rust - Production Reality Check

What Actually Happens When You Ship Code With These Languages

javascript
/compare/python-javascript-go-rust/production-reality-check
25%
howto
Recommended

MySQL to PostgreSQL Production Migration: Complete Step-by-Step Guide

Migrate MySQL to PostgreSQL without destroying your career (probably)

MySQL
/howto/migrate-mysql-to-postgresql-production/mysql-to-postgresql-production-migration
23%

Recommendations combine user behavior, content similarity, research intelligence, and SEO optimization