Skip to main content
Back to Blog
Tutorial5 min read

How to Deploy a Cursor Project to Production (The Complete Guide)

Cursor gives you real code in a real IDE — but that doesn't mean it's production-ready. Here's how to deploy a Cursor-built project with CI/CD, testing, and the hardening steps AI skips.

Share:

Cursor is different from other AI coding tools. You're working in a real IDE, with real files, real git, and a real terminal. The code it generates is often impressively functional. But that creates a dangerous false confidence.

Because the code looks professional — proper TypeScript, clean component structure, reasonable naming — it's easy to assume it's production-ready. It usually isn't. Here's what to check and fix before deploying.

1. Audit the code Cursor generated

Before deploying anything, do a focused review. Cursor writes code that solves the immediate problem but often misses the broader context.

Common gaps we find in Cursor projects:

  • Error handling only covers the happy path
  • TypeScript types are loose — any scattered throughout
  • No input validation on API endpoints
  • Authentication checks missing on sensitive routes
  • Database queries with no indexes or pagination
  • Secrets hardcoded or in the wrong environment files

For a deeper dive into what senior developers typically find, read what a senior dev finds when reviewing Cursor code.

2. Add tests before deploying

This is the step most people skip — and the one that hurts the most later. Cursor doesn't generate tests unless you explicitly ask it to, and even then they're often superficial.

At minimum, write tests for:

  • Authentication flows — sign up, log in, password reset, token refresh
  • Payment processing — if you charge money, test every path
  • Data mutations — any operation that writes to your database
npm install -D vitest @testing-library/react

You don't need 100% coverage. You need confidence that the critical paths work. Start with integration tests on your API routes and expand from there.

3. Set up CI/CD

Cursor gives you a local development experience but no deployment pipeline. Set one up before your first deploy:

GitHub Actions example:

name: CI
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm run lint
      - run: npm test

Connect your repo to Vercel, Railway, or your hosting provider so that passing CI automatically triggers deployment.

4. Lock down environment variables

Cursor often generates .env files with example values or puts secrets in the wrong places. Audit every environment variable:

  • Client-safe variables (public keys, API URLs): prefixed with NEXT_PUBLIC_ or VITE_
  • Server-only variables (secret keys, database URLs): no prefix, never exposed to the browser

Check your .gitignore to make sure .env.local and .env are excluded. If secrets have ever been committed to git, rotate them immediately — git history is permanent.

5. Add proper error handling

Cursor's error handling typically looks like this:

try {
  const data = await fetchSomething();
  return data;
} catch (error) {
  console.log(error);
}

That's not production error handling. Replace it with:

try {
  const data = await fetchSomething();
  return data;
} catch (error) {
  logger.error("Failed to fetch something", { error, userId });
  throw new AppError("Something went wrong", 500);
}

Install error monitoring (Sentry is the standard) so production errors get reported immediately instead of silently logged to a console nobody reads.

6. Tighten TypeScript

Cursor generates TypeScript that compiles but isn't strict. Enable strict mode in your tsconfig.json:

{
  "compilerOptions": {
    "strict": true,
    "noUncheckedIndexedAccess": true
  }
}

Fix the resulting errors. Yes, there will be many. Each one is a potential runtime bug that TypeScript just caught for you.

7. Add rate limiting and security headers

Cursor rarely adds rate limiting or security headers unless asked. For a Next.js app:

  • Add rate limiting to authentication and form submission routes
  • Configure security headers (CSP, HSTS, X-Frame-Options) in next.config.ts
  • Enable CORS restrictions on API routes

For a comprehensive security review, use our vibe coding security checklist.

8. Deploy to production

With tests passing, CI configured, and security hardened, deploy:

  • Vercel for Next.js apps — npx vercel --prod
  • Railway for apps needing persistent processes
  • AWS/GCP for apps needing more infrastructure control

Set up monitoring dashboards, error alerting, and uptime checks. The deploy is just the beginning — production is an ongoing responsibility.

The deployment checklist

Before going live:

  • [ ] Code reviewed for security gaps, loose types, and missing error handling
  • [ ] Tests covering authentication, payments, and data mutations
  • [ ] CI/CD pipeline running lint, type-check, and tests on every push
  • [ ] Environment variables audited — secrets server-side only
  • [ ] Error monitoring installed and alerting configured
  • [ ] Rate limiting on authentication and form endpoints
  • [ ] Security headers configured
  • [ ] Database queries indexed and paginated
  • [ ] Custom domain with HTTPS enforced
  • [ ] Tested on real devices and browsers

Need help?

Cursor gives you a head start, but production readiness requires hardening that AI skips. If you want a professional review before launch, request a free audit. We specialise in Cursor projects and will send you a prioritised list of what needs fixing.

For the full production readiness checklist covering all vibe-coded apps, see our complete production checklist.

Get articles like this in your inbox

Practical tips on shipping vibe-coded apps. No spam.

Want to know where your app stands?

Get a free 5-point security snapshot from our dev team — no strings attached.