Menu

Deploy to Vercel

I've tried many deployment platforms, and ultimately recommend using Vercel for deployment, especially for beginners. Using Vercel can save a significant amount of unrewarding work.

Besides Vercel, I suggest trying Dokploy or Coolify. These two tools use Docker deployment, which means they can't leverage edge runtime features.

I don't recommend beginners attempt CloudFlare deployment for two main reasons:

  • CloudFlare only has Edge runtime. All server-side code must be explicitly specified to use edge runtime to run
  • CloudFlare's Edge runtime lacks some important features compared to Vercel. For example, timeout duration - CloudFlare only has 10 seconds while Vercel has 300 seconds. 10 seconds is insufficient for AI image and video generation, or even many text conversations.

Vercel Deployment Process

After registering for Vercel, find the "New Project" button to start deployment:

New Project

You can either fill in environment variables at this step or click the "Deploy" button directly to start deployment, then fill in environment variables in the settings page after deployment is complete:

Deploy

After successful deployment, go to the settings page and open Environment Variables to fill in environment variables:

Environment Variables

You need to redeploy after updating environment variables for them to take effect:

redeploy

Then go to the Domains page, click the "Add Domain" button, and first add the domain without "www":

Add Domain

Add Domain

Add Domain

Don't configure DNS yet - wait until after adding the "www" domain to configure them together:

Add Domain

Add Domain

Then go to CloudFlare to configure DNS, adding the following records:

A Record:
your-domain.com -> 76.223.126.88
Enable Proxy
 
CNAME Record:
www.your-domain.com -> cname-china.vercel-dns.com
Enable Proxy

Why not use Vercel's provided DNS addresses? Because Vercel's provided DNS addresses cannot be accessed from China, while the addresses provided above can be accessed from China. No one wants to miss out on the Chinese market.

Configure CloudFlare SSL/TLS

In the CloudFlare SSL/TLS page, select "Full (Strict)" and enable "Always Use HTTPS":

SSL/TLS

提示:

Deploy to Vercel, you must select "Full (Strict)", otherwise you will encounter multiple redirects, which will cause the product to fail to access.

always use https

Now, you can open your SaaS product at the production address.

If You Want to Deploy with Docker

If you don't want to use Vercel deployment and prefer to use Docker deployment, you need to make a small modification: search globally for export const runtime = "edge" and comment it out. This line of code is an edge runtime feature, while Docker deployment is based on Node runtime.