vercel/next.js · error

Each route must start with '/': ${route}

Error message

Each route must start with '/': ${route}

What it means

Thrown by parseCli during route validation when any individual route in --routes does not begin with a leading slash. App Router route paths are always root-absolute (/, /dashboard), so a missing slash indicates a user mistake that would silently fail to match a route.

Source

Thrown at bench/render-pipeline/client-trace.ts:169

    if (!rawArg.startsWith('--')) continue
    const eq = rawArg.indexOf('=')
    if (eq === -1) {
      args.set(rawArg.slice(2), 'true')
    } else {
      args.set(rawArg.slice(2, eq), rawArg.slice(eq + 1))
    }
  }

  const routes = (args.get('routes') ?? '/,/dashboard,/docs,/blog,/tailwind')
    .split(',')
    .map((route) => route.trim())
    .filter(Boolean)
  if (routes.length === 0) {
    throw new Error('--routes cannot be empty')
  }
  for (const route of routes) {
    if (!route.startsWith('/')) {
      throw new Error(`Each route must start with '/': ${route}`)
    }
  }

  const samples = parseNumberArg(args, 'samples', 3)
  if (samples < 1) {
    throw new Error(`--samples must be at least 1, got ${samples}`)
  }
  // CDP rejects rates below 1 (1 = no throttling).
  const cpuThrottle = parseNumberArg(args, 'cpu-throttle', 4)
  if (cpuThrottle < 1) {
    throw new Error(`--cpu-throttle must be at least 1, got ${cpuThrottle}`)
  }

  const timestamp = new Date().toISOString().replace(/[:.]/g, '-')

  return {
    appDir: resolve(REPO_ROOT, args.get('app-dir') ?? 'bench/basic-app'),
    routes,

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Prefix every route with /, e.g. --routes=/,/dashboard.
  2. If you pasted a full URL, extract just the pathname.
  3. Re-run with --help to confirm the expected format.

Example fix

// before
--routes=dashboard,/docs
// after
--routes=/dashboard,/docs
Defensive patterns

Strategy: validation

Validate before calling

function normalizeRoutes(raw: string): string[] {
  return raw.split(',').map(r => r.trim()).filter(Boolean).map(r =>
    r.startsWith('/') ? r : `/${r}`
  )
}

Type guard

const isValidRoute = (r: string): boolean => r.startsWith('/')

Try / catch

null

Prevention

When it happens

Trigger: Passing --routes=dashboard,docs or --routes=http://localhost/x; forgetting the leading slash on the first segment.

Common situations: Typing a bare path segment; pasting a full URL instead of a path; an off-by-one in a script that strips the slash.

Related errors


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/a635a28aa202897a. Report an issue: GitHub.