vercel/next.js · error · Error

Specified basePath has to start with a /, found

Error message

Specified basePath has to start with a /, found "${result.basePath}"

What it means

basePath validation in assignDefaultsAndValidate: the value is non-empty and not '/', but fails startsWith('/') — it is a relative path like 'docs'. Path prefixes must be absolute, so the validator rejects it echoing the received basePath.

Solutions

  1. Prefix basePath with a leading slash, e.g. /docs.
Defensive patterns

Strategy: validation

When it happens

Trigger: basePath does not start with a forward slash.

Common situations: basePath: 'docs' instead of '/docs' in next.config.


AI-assisted analysis of vercel/next.js@34433fd12e (2026-08-19). Data as JSON: /api/errors/0e7b455cba1f88be. Report an issue: GitHub.

Appendix: source

Thrown at packages/next/src/server/config.ts:696

      `Specified assetPrefix is not a string, found type "${typeof result.assetPrefix}" https://nextjs.org/docs/messages/invalid-assetprefix`
    )
  }

  if (typeof result.basePath !== 'string') {
    throw new Error(
      `Specified basePath is not a string, found type "${typeof result.basePath}"`
    )
  }

  if (result.basePath !== '') {
    if (result.basePath === '/') {
      throw new Error(
        `Specified basePath /. basePath has to be either an empty string or a path prefix"`
      )
    }

    if (!result.basePath.startsWith('/')) {
      throw new Error(
        `Specified basePath has to start with a /, found "${result.basePath}"`
      )
    }

    if (result.basePath !== '/') {
      if (result.basePath.endsWith('/')) {
        throw new Error(
          `Specified basePath should not end with /, found "${result.basePath}"`
        )
      }

      if (result.assetPrefix === '') {
        result.assetPrefix = result.basePath
      }
    }
  }

  if (result?.images) {

View on GitHub (pinned to 34433fd12e)