vercel/next.js · error · Error

Specified basePath /. basePath has to be either an empty…

Error message

Specified basePath /. basePath has to be either an empty string or a path prefix"

What it means

basePath validation in assignDefaultsAndValidate: the value is the string '/'. A lone slash is not a usable path prefix — the root is expressed as an empty string — so the validator rejects it and states basePath must be '' or a real path prefix like '/docs'.

Solutions

  1. Set basePath to an empty string or a path prefix like /docs, not just /.
Defensive patterns

Strategy: validation

When it happens

Trigger: basePath is set to just '/' or an invalid prefix.

Common situations: basePath must be empty or a real path prefix like '/docs', not '/'.


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

Appendix: source

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

      }
    }
  }

  if (typeof result.assetPrefix !== 'string') {
    throw new Error(
      `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 === '') {

View on GitHub (pinned to 34433fd12e)