Vercel Configuration

Complete guide for setting up Nexting with Vercel.

Basic Setup

Vercel uses a vercel.json file to configure rewrites. This file should be placed in your project root.

vercel.json
{
  "rewrites": [
    {
      "source": "/__verify__",
      "destination": "https://api.nexting.ai/proxy/YOUR_PROJECT_KEY/__verify__"
    },
    {
      "source": "/blog/:path*",
      "destination": "https://api.nexting.ai/proxy/YOUR_PROJECT_KEY/blog/:path*"
    }
  ]
}

Wildcard Patterns

Use :path* to match any path under a directory. This way you don't need to add a new rule for each page.

Merging with Existing Configuration

If you already have a vercel.json, add the Nexting rewrites to your existing rewrites array:

vercel.json
1{
2 "framework": "nextjs",
3 "buildCommand": "npm run build",
4 "rewrites": [
5 // Your existing rewrites
6 {
7 "source": "/api/:path*",
8 "destination": "/api/:path*"
9 },
10 // Add Nexting rewrites below
11 {
12 "source": "/__verify__",
13 "destination": "https://api.nexting.ai/proxy/YOUR_KEY/__verify__"
14 },
15 {
16 "source": "/blog/:path*",
17 "destination": "https://api.nexting.ai/proxy/YOUR_KEY/blog/:path*"
18 }
19 ]
20}

Rule Order Matters

Vercel processes rewrites in order. Place specific rules before wildcard rules. If you have a catch-all route, put Nexting rules before it.

Next.js Configuration

For Next.js projects, you can also configure rewrites in next.config.js:

next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
  async rewrites() {
    return [
      {
        source: '/__verify__',
        destination: 'https://api.nexting.ai/proxy/YOUR_KEY/__verify__',
      },
      {
        source: '/blog/:path*',
        destination: 'https://api.nexting.ai/proxy/YOUR_KEY/blog/:path*',
      },
    ]
  },
}

module.exports = nextConfig
If you use both vercel.json and next.config.js rewrites, they are merged together.vercel.json takes precedence.

Deployment

1

Add the configuration

Add or update your vercel.json file.

2

Commit and push

bash
git add vercel.json
git commit -m "Add SEO pages proxy"
git push origin main
3

Wait for deployment

Vercel will automatically deploy your changes. This typically takes 30-60 seconds.

4

Verify in Nexting

Go to your project settings in Nexting and click "Verify Configuration".

Using Environment Variables

For better security and flexibility, you can use environment variables in next.config.js:

next.config.js
const NEXTING_KEY = process.env.NEXTING_PROJECT_KEY

const nextConfig = {
  async rewrites() {
    return [
      {
        source: '/__verify__',
        destination: `https://api.nexting.ai/proxy/${NEXTING_KEY}/__verify__`,
      },
      {
        source: '/blog/:path*',
        destination: `https://api.nexting.ai/proxy/${NEXTING_KEY}/blog/:path*`,
      },
    ]
  },
}

module.exports = nextConfig

Then add NEXTING_PROJECT_KEY to your Vercel project's Environment Variables.

Common Issues

× 404 Not Found

The rewrite rules haven't taken effect yet.

Wait for deployment to complete and try again

× CORS Error

You're trying to access the proxy endpoint directly from JavaScript.

The proxy only works for server-side requests (rewrites), not client-side fetch

× Wrong page content

Another route in your app is matching before the rewrite rule.

Check that you don't have a file or route at the same path

Related Guides