vercel/next.js · error

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

Error message

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

What it means

When basePath is non-empty, the value '/' is explicitly rejected because it would prefix routes with '//'. Normalization throws if `basePath === '/'`, telling you basePath must be either an empty string (default, root serving) or a real path prefix like '/docs'.

Source

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

      }
    }
  }

  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 0ae8c72462)

Solutions

  1. Set basePath to '' (empty string) to serve from root, or omit the key
  2. Use a real prefix like `basePath: '/app'` if you want a sub-path

Example fix

// before
module.exports = { basePath: '/' }
// after
module.exports = { basePath: '' }
Defensive patterns

Strategy: validation

Validate before calling

if (basePath === '/') basePath = ''

Prevention

When it happens

Trigger: Setting `basePath: '/'` in next.config. The check runs only when basePath !== ''.

Common situations: Assuming '/' means 'serve from root' (it actually means empty string). Setting basePath to the root path to 'be explicit'. Copying a trailing-slash pattern from another framework.

Related errors


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