API Routes Not Working, Persistent Config Warning, No Overrides

Current versus Expected behavior

Current:

  • I always see the warning:

“Configuration Settings in the current Production deployment differ from your current Project Settings.”

  • My API routes (e.g., /api/test, /api/lemon-subscriptions) do not work and never show up in the Vercel logs.

  • No matter how many times I redeploy, the warning persists and API routes are not available.

Expected:

  • The warning should disappear after redeploying with correct settings.

  • API routes should be available and show up in logs.

Code, configuration, and steps that reproduce this issue:

  • My vercel.json (in the root of my repo):
  {
    "version": 2,
    "builds": [
      {
        "src": "api/*.js",
        "use": "@vercel/node"
      },
      {
        "src": "package.json",
        "use": "@vercel/static-build",
        "config": {
          "distDir": "dist"
        }
      }
    ],
    "redirects": [
      {
        "source": "/(.*)",
        "has": [
          {
            "type": "host",
            "value": "www.getmashgpt.com"
          }
        ],
        "destination": "https://getmashgpt.com/$1",
        "permanent": true
      }
    ],
    "rewrites": [
      { "source": "/(.*)", "destination": "/index.html" }
    ]
  }

  • No overrides are set in my project settings.

  • All environment variables are set for Production.

I have tried:

  • Multiple redeploys (including after code changes)

  • Disconnecting and reconnecting my GitHub repo

  • Confirming the correct repo and branch are linked

  • API routes never show up in logs, and the warning never goes away.

Project information (URL, framework, environment, project settings)

  • Project URL: getmashgpt.com

  • Framework: Vite (with serverless functions in /api/)

  • Environment: Production (issue also occurs in Preview)

Project Settings:

  • No overrides

  • Output directory: dist

  • Build command: default

  • All environment variables set for Production

Thanks for any help offered!

Hi, Hobo! Welcome to the Vercel Community :waving_hand:

I think that the main problem is in your vercel.json configuration, specifically with your rewrites section. It’s currently redirecting all requests (including API routes) to /index.html:

"rewrites": [
  { "source": "/(.*)", "destination": "/index.html" }
]

So all your rewrites are caught by this catch-all rewrite before they can be processed by your API handlers. You’d need to modify your rewrites to exclude API routes.

{
  "version": 2,
  "builds": [
    {
      "src": "api/*.js",
      "use": "@vercel/node"
    },
    {
      "src": "package.json",
      "use": "@vercel/static-build",
      "config": {
        "distDir": "dist"
      }
    }
  ],
  "redirects": [
    {
      "source": "/(.*)",
      "has": [
        {
          "type": "host",
          "value": "www.getmashgpt.com"
        }
      ],
      "destination": "https://getmashgpt.com/$1",
      "permanent": true
    }
  ],
  "rewrites": [
    { "source": "/api/(.*)", "destination": "/api/$1" },
    { "source": "/(.*)", "destination": "/index.html" }
  ]
}

Could you give that a go and let us know how you get on?

1 Like

The issue was resolved by removing the legacy “builds” property from the vercel.json file. Previously, having the “builds” property caused conflicts with Vercel’s modern deployment system, which now auto-detects static builds and serverless functions. By switching to only using the modern “rewrites” and “redirects” properties, Vercel was able to properly route /api/* requests to the backend serverless functions, while all other routes correctly fall back to the SPA. This change allowed the API endpoints to work as intended and fixed the persistent 404 and routing issues.

This was the fix:

{
  "version": 2,
  "redirects": [
    {
      "source": "/(.*)",
      "has": [
        {
          "type": "host",
          "value": "www.getmashgpt.com"
        }
      ],
      "destination": "https://getmashgpt.com/$1",
      "permanent": true
    }
  ],
  "rewrites": [
    {
      "source": "/api/(.*)",
      "destination": "/api/$1"
    },
    {
      "source": "/(.*)",
      "destination": "/index.html"
    }
  ]
}

Thanks for your help!!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.