How to Deploy a Vibe-Coded App to Production Without Breaking Everything - VibeDoctor 
← All Articles ⚙️ Configuration & DevOps High

How to Deploy a Vibe-Coded App to Production Without Breaking Everything

Step-by-step guide to deploying AI-generated apps safely. Covers environment variables, secrets, SSL, security headers, monitoring, and the checks to run before going live.

SEC-006 SEC-014 SSL-001 HDR-001 CFG-002 CFG-005

Quick Answer

To deploy a vibe-coded app safely: move all secrets to environment variables, set up HTTPS with auto-renewal, add security headers, configure error tracking, set up uptime monitoring, run npm audit fix, test the production build locally, deploy to your hosting platform, verify the live URL, and run a full diagnostic scan against the deployed app. This guide covers every step from local development to production for apps built with Cursor, Bolt, Lovable, Claude Code, and other AI coding tools.

The Deployment Gap in Vibe Coding

AI coding tools are excellent at building features. They are not excellent at preparing code for production. The app works on localhost. The demo looks great. But between "it runs on my machine" and "it runs safely for real users," there is a list of things that AI tools consistently skip.

This guide covers every step of that gap. It is not specific to any hosting platform - whether you deploy to Vercel, Netlify, Railway, Render, Fly.io, a VPS, or anywhere else, the principles and checks are the same.

Step 1: Separate Secrets from Code

This is the most critical step and the one most often skipped in vibe-coded projects.

What to move to environment variables

How to do it

  1. Create a .env file in your project root with all secrets
  2. Add .env to your .gitignore (verify it is actually ignored with git status)
  3. Create a .env.example file with the variable names but no values - this documents what env vars are needed
  4. Update your code to read from process.env instead of hardcoded values
  5. If secrets were ever committed to git history, rotate them immediately - removing from current code does not remove from history

Frontend vs backend variables

In Next.js, variables prefixed with NEXT_PUBLIC_ are embedded in the browser bundle and visible to anyone. In Vite, it is VITE_. Never put secret keys behind these prefixes. Only public, non-sensitive values (API base URLs, public Stripe keys, feature flags) should use public prefixes.

Step 2: Set Up HTTPS

Every production app needs HTTPS. No exceptions.

Managed platforms (Vercel, Netlify, Railway)

HTTPS is automatic. Your app gets a valid SSL certificate when you deploy. Verify it works by visiting your URL with https:// and checking that the browser shows a lock icon. Also verify that http:// redirects to https://.

Self-hosted (VPS, Docker)

Use Let's Encrypt with a reverse proxy like Caddy (auto-HTTPS built in) or Nginx with Certbot. Set up auto-renewal so your certificate does not expire without warning. A typical Caddy configuration handles HTTPS automatically with zero additional config.

Custom domains

If you are using a custom domain, make sure your DNS records point to the right server and your hosting platform's SSL covers the custom domain. Some platforms require you to verify domain ownership before issuing a certificate.

Step 3: Add Security Headers

Security headers tell the browser how to handle your app's content. AI-generated apps almost never include them. Adding them takes 5 minutes and prevents entire categories of attacks.

Essential headers

Header Value What It Prevents
Strict-Transport-Security max-age=31536000; includeSubDomains Downgrade attacks from HTTPS to HTTP
X-Content-Type-Options nosniff MIME type sniffing attacks
X-Frame-Options DENY Clickjacking via iframe embedding
Referrer-Policy strict-origin-when-cross-origin URL leaking via referrer headers
Permissions-Policy camera=(), microphone=(), geolocation=() Unauthorized access to device features

Where to add them

Vercel: Add a headers section to vercel.json.
Netlify: Add to _headers file or netlify.toml.
Next.js: Add to the headers() function in next.config.js.
Express: Use the helmet npm package (one line of code).
Nginx/Caddy: Add directly to the server configuration.

Step 4: Build and Test for Production

Your development build and production build are different. Always test the production build before deploying.

For Next.js / React apps

npm run build
npm run start

Visit http://localhost:3000 and test the critical paths: login, main feature, payment (if applicable). Look for:

For static sites

Build the static output and serve it locally with a simple HTTP server. Check that all links work and no resources 404.

Step 5: Configure Error Tracking

In development, you see errors in your terminal. In production, errors happen silently unless you capture them.

Options

The key requirement: when a user hits an error in production, you should know about it without them telling you.

Step 6: Set Up Monitoring

Monitoring tells you when something breaks after deployment. You need three types:

Uptime monitoring

A service that pings your URL every few minutes and alerts you when it goes down. Free options exist, and VibeDoctor includes uptime monitoring on paid plans with checks as frequent as every minute.

SSL certificate monitoring

Auto-renewal usually works, but when it fails, your users see a security warning instead of your app. Set up alerts for certificate expiry at least 14 days in advance.

Performance monitoring

Track your Lighthouse scores over time. A score that drops from 75 to 40 after a deployment tells you something went wrong. VibeDoctor tracks performance scores across scans so you can see the trend.

Step 7: Run Pre-Deployment Checks

Before you push the deploy button, run these checks:

  1. npm audit - fix any critical or high dependency vulnerabilities
  2. Environment variables - verify all required env vars are set on your hosting platform
  3. Build succeeds - npm run build completes without errors
  4. No .env in git - git status should not show .env
  5. No localhost URLs - search your code for localhost and 127.0.0.1 in non-development files
  6. CORS configured - if your frontend and backend are on different domains, set the correct allowed origins (not *)

Step 8: Deploy

The actual deployment depends on your platform:

Vercel / Netlify

Connect your GitHub repository. Push to the main branch. The platform builds and deploys automatically. Set environment variables in the platform's dashboard (not in the repository).

Railway / Render / Fly.io

Similar to Vercel but supports backend services. Connect your repo, configure environment variables, and deploy. These platforms handle SSL and domain routing for you.

VPS (DigitalOcean, Hetzner, etc.)

You manage everything: reverse proxy, SSL certificates, process management, and deployments. Use Docker Compose for reproducible builds. Use a reverse proxy like Caddy for automatic HTTPS. Use PM2 or systemd for process management.

Step 9: Verify the Live Deployment

After deploying, verify that the live app works correctly:

  1. HTTPS - visit with https:// and check the lock icon
  2. HTTP redirect - visit with http:// and verify it redirects to HTTPS
  3. Critical paths - test login, main feature, and payment flow manually
  4. Console errors - open browser DevTools and check for JavaScript errors
  5. Mobile - test on a real phone or Chrome DevTools mobile emulation
  6. API endpoints - verify your API returns data (not CORS errors or 500s)

Step 10: Run a Full Diagnostic Scan

The final step. Run a comprehensive scan against your live deployed URL and your connected GitHub repository.

A VibeDoctor scan checks both:

Fix any critical or high findings before sharing your app publicly. Review medium findings and address what you can. This is your final quality gate between "deployed" and "ready for users."

Post-Deployment Checklist

Check Frequency Tool
Uptime monitoring Continuous (every 1-5 min) VibeDoctor, UptimeRobot, or similar
SSL certificate expiry Daily check, 14-day alert VibeDoctor, SSL monitoring service
Dependency vulnerabilities Weekly npm audit, VibeDoctor scan
Performance score After every deployment Lighthouse, VibeDoctor scan
Full diagnostic After every major coding session VibeDoctor (1 free scan/day)
Error tracking review Daily Sentry, LogRocket, or logs

FAQ

Which hosting platform is best for vibe-coded apps?

For frontend-heavy apps (Next.js, React), Vercel and Netlify are the easiest - they handle SSL, CDN, and deployments automatically. For full-stack apps with a backend, Railway and Render provide managed hosting with database support. For maximum control (and responsibility), a VPS from Hetzner or DigitalOcean gives you the most flexibility. The security and quality checks in this guide apply to all of them.

My AI tool already deployed my app. Should I redo the deployment?

Not necessarily. Go through this guide as a verification checklist against your existing deployment. If you find critical issues (exposed secrets, missing HTTPS, no auth on API routes), fix them in place. You only need to redo the deployment if the fundamental configuration is wrong (secrets in code, no environment variable support on the platform).

How do I handle environment variables across development and production?

Use .env for local development (with .env.example committed as documentation). Set production variables in your hosting platform's dashboard - never in code or git. For staging environments, use a separate set of variables with test credentials. Never share credentials between environments.

What if my app is already live and I skipped these steps?

Go through them now. The most urgent fixes are: remove any hardcoded secrets and rotate the credentials (Step 1), verify HTTPS is working (Step 2), and add authentication to unprotected API routes (not covered here but critical - see our API route security guide). Then work through the remaining steps at your own pace. Better late than never - most exploits happen after an app has been live for days or weeks, not minutes.

Diagnose your codebase - free

VibeDoctor checks for SEC-006, SEC-014, SSL-001, HDR-001, CFG-002, CFG-005 and 128 other issues across 15 diagnostic areas - security, performance, code quality, and more.

SCAN MY APP →
← Back to all articles View all 129+ checks →