LeakyVibe

Guides · Updated 2026-11-06

Leftover /api/seed, /api/test, /admin and unprotected AI chat routes: find them before strangers do

Short answer: AI coding tools often leave temporary helper routes in your shipped app — /api/seed, /api/test, /api/reset, /api/debug, or an /admin page with no login — and they also wire an /api/chat (or similar) route that calls OpenAI with your secret key and no session or rate limit. Next.js Route Handlers are public HTTP endpoints: anyone who can guess the URL can call them. Find them from the outside by guessing common paths, watching the Network tab, and trying the same URLs logged out. Delete what you don't need, require a session (and an admin role for admin tools), rate-limit anything that costs money, and set a hard spend limit in your AI provider.

Does your app have this problem? Free scan, 15 sec, no sign-up

or watch it scan our demo app ▶

Why leftover helper routes show up in production

When you ask an AI tool to "add sample data", "reset the database", or "build a quick admin page", it usually creates a Route Handler or page under a short path: /api/seed, /api/test, /api/reset, /api/debug, /api/dev, or /admin. Those are handy while you're iterating. The problem is they often still work after you publish — with no login check — because nothing in the framework hides them.

Next.js is explicit about this. Its Backend for Frontend guide says Route Handlers are public HTTP endpoints and any client can access them (https://nextjs.org/docs/app/guides/backend-for-frontend). The Authentication guide says to treat Route Handlers with the same security considerations as public-facing API endpoints, verify the session inside the handler, and return 401 if the caller isn't signed in or 403 if they lack the right role (https://nextjs.org/docs/app/guides/authentication). A page that redirects to login does not protect a related /api/... route — each handler is its own entry point.

Common leftover patterns in vibe-coded apps:

  • /api/seed or /api/reset that inserts demo rows, wipes tables, or recreates a "fresh" database.
  • /api/test, /api/debug, /api/dev that dump config, run arbitrary SQL, or echo environment details.
  • /admin (or /dashboard/admin) that lists users, edits rows, or triggers emails with no auth check beyond "you found the URL".
  • Server Actions left exported from those pages that still accept a direct POST even when the UI is gone (Next.js notes Server Actions are reachable via POST and must verify auth inside each one: https://nextjs.org/docs/app/guides/data-security).

The other common leak: an unprotected AI chat endpoint

A second pattern shows up when the AI tool adds a chat box. It usually creates something like /api/chat (or /api/ai, /api/completion) that reads OPENAI_API_KEY (or another provider secret) on the server and streams a reply. That is the right place for the secret — not in the browser — but the route itself still needs a gate. Without a signed-in session, a per-user or per-IP rate limit, and a spending cap at the provider, anyone can POST to the URL and run up your bill.

Next.js's own Backend for Frontend guide recommends rate limiting expensive operations and verifying credentials before granting access, and says not to rely on Proxy alone for authentication (https://nextjs.org/docs/app/guides/backend-for-frontend). On the provider side, OpenAI lets you set spend alerts (notify, traffic continues) and hard spend limits (affected requests return 429 with organization_spend_limit_exceeded or project_spend_limit_exceeded). Those are separate from the monthly usage limit OpenAI assigns by usage tier (https://developers.openai.com/api/docs/guides/spend-limits).

How to find them from outside (no login needed)

You do not need the source code. Do this against your live URL (and any public preview URL) from a private browser window so you are logged out:

  1. Guess common paths. Try /api/seed, /api/test, /api/reset, /api/debug, /api/dev, /api/setup, /api/migrate, /api/admin, /admin, /api/chat, /api/ai, /api/completion. A 200 with JSON, HTML that looks like an admin UI, or a long-running streamed reply is a hit. A clean 401/403/404 is what you want for helpers you no longer need.
  2. Open DevTools → Network, use your own app normally (sign up, chat, admin clicks), and note every /api/... request. Then open the same URLs in a private window with no cookies. If they still succeed, the route is not checking a session.
  3. For chat-like routes, send a tiny POST with a harmless body (for example {"messages":[{"role":"user","content":"ping"}]}) without a cookie. If you get a model reply or a provider error about billing/keys, the endpoint is reachable from the outside.
  4. Search your repo (or ask your AI tool) for route.ts / route.js files and for strings like seed, reset, debug, test, admin, openai, chat.completion. Anything under app/api/ that mutates data or calls a paid API is on the public internet once deployed.

Vercel Deployment Protection can lock down preview URLs (Standard Protection covers all deployments except production domains; All Deployments covers production too) with Vercel Authentication or other methods (https://vercel.com/docs/deployment-protection). That helps keep strangers off previews, but it does not replace per-route checks on your public production domain — leftover /api/seed or /api/chat on production stay callable unless your code rejects them.

How to lock them down

  1. Delete helper routes you only needed during development (/api/seed, /api/test, /api/reset, /api/debug, throwaway /admin). Redeploy so the old handlers are gone from production and from old previews you no longer need.
  2. For any admin or mutation route you keep: verify the session inside the Route Handler and check an admin role. Return 401 when there is no session and 403 when the role is wrong — the pattern Next.js documents for Route Handlers (https://nextjs.org/docs/app/guides/authentication).
  3. For /api/chat (or any route that calls a paid AI API): require a signed-in user, rate-limit per user and per IP, keep the provider secret in a server-only env var (never NEXT_PUBLIC_ / VITE_), and validate the request body size and shape before calling the model.
  4. In your AI provider dashboard, set a spend alert and a hard spend limit you can afford. For OpenAI: Organization limits or Project settings → Limits → Edit spend limit, and turn on Enforce a hard limit if you want requests to fail at the cap (https://developers.openai.com/api/docs/guides/spend-limits).
  5. Turn on Vercel Standard Protection (or stronger) so preview and generated deployment URLs are not a second public copy of the same helpers (https://vercel.com/docs/deployment-protection).

Example shape for a protected Route Handler (adapt to your own session helper):

import { verifySession } from '@/app/lib/dal'

export async function POST(request: Request) {
  const session = await verifySession()
  if (!session) return new Response(null, { status: 401 })
  if (session.role !== 'admin') return new Response(null, { status: 403 })
  // ...only then seed / reset / admin work
}

Prompt to give your AI coding tool

Audit my app for leftover helper routes and unprotected AI endpoints before production. List every Route Handler and Server Action under paths like /api/seed, /api/test, /api/reset, /api/debug, /api/dev, /api/setup, /api/migrate, /api/admin, /admin, /api/chat, /api/ai, /api/completion (and any similar names). For each one: (1) say whether it mutates data, dumps config, or calls a paid AI API; (2) say whether it verifies a signed-in session and, for admin tools, an admin role; (3) say whether it rate-limits by user and IP. Then: delete helpers that are only for local/dev use; for anything we keep, add session (+ role) checks that return 401/403, add rate limits on paid AI routes, and keep provider secrets in server-only env vars (never NEXT_PUBLIC_ or VITE_). Do not print any secret values. Summarize the files you changed and the routes that remain public on purpose.

Quick checklist

  1. No /api/seed, /api/test, /api/reset, /api/debug (or similar) reachable on production without auth.
  2. Any /admin UI and its API routes require a signed-in admin; logged-out requests get 401/403.
  3. /api/chat (or equivalent) requires a session, is rate-limited, and uses a server-only provider key.
  4. Hard spend limit (and a spend alert) set in your AI provider.
  5. Vercel preview / generated deployment URLs protected; production leftovers removed or gated in code.
  6. Private-window check of the common paths above returns 401, 403, or 404 — not 200 with data or a model reply.

The free LeakyVibe scan at the top of this page checks your live site from the outside for secret keys in public JavaScript, Supabase tables that answer the public key, and missing security headers. It does not fully audit every leftover API route or prove that /api/chat requires a session — still useful as a first pass, then use the path checks and checklist above for helpers and AI endpoints.

Related: if a key already leaked into public JavaScript, start here: https://leakyvibe.com/guides/leaked-api-key-what-to-do — and for NEXT_PUBLIC_ / VITE_ mistakes: https://leakyvibe.com/guides/is-my-vercel-app-leaking-environment-variables

Official sources (checked 2026-11-06): Next.js, "How to implement authentication in Next.js" — Route Handlers (https://nextjs.org/docs/app/guides/authentication); Next.js, "How to use Next.js as a backend for your frontend" — public endpoints, rate limiting, verify credentials (https://nextjs.org/docs/app/guides/backend-for-frontend); Next.js, "Data Security" — Server Actions reachable via POST, audit route.ts (https://nextjs.org/docs/app/guides/data-security); Vercel, "Deployment Protection" (https://vercel.com/docs/deployment-protection); OpenAI, "Spend limits" (https://developers.openai.com/api/docs/guides/spend-limits).

Check your app for this now

Free scan · about 15 seconds · no sign-up

Passive, read-only checks. Only scan apps you own or have permission to test.