vercel/next.js · error

rewrites, redirects, and headers are not applied when export

Error message

rewrites, redirects, and headers are not applied when exporting your application, detected (${customRoutes.join(', ')}). See more info here: https://nextjs.org/docs/messages/export-no-custom-routes

What it means

Error "rewrites, redirects, and headers are not applied when exporting your application, detected (${customRoutes.join(', ')}). See more info here: https://nextjs.org/docs/messages/export-no-custom-routes" thrown in vercel/next.js.

Source

Thrown at packages/next/src/export/index.ts:252

  if (!options.silent && !options.buildExport) {
    Log.info(`using build directory: ${distDir}`)
  }

  const buildIdFile = join(distDir, BUILD_ID_FILE)

  if (!existsSync(buildIdFile)) {
    throw new ExportError(
      `Could not find a production build in the '${distDir}' directory. Try building your app with 'next build' before starting the static export. https://nextjs.org/docs/messages/next-export-no-build-id`
    )
  }

  const customRoutes = (['rewrites', 'redirects', 'headers'] as const).filter(
    (config) => typeof nextConfig[config] === 'function'
  )

  if (!hasNextSupport && !options.buildExport && customRoutes.length > 0) {
    Log.warn(
      `rewrites, redirects, and headers are not applied when exporting your application, detected (${customRoutes.join(
        ', '
      )}). See more info here: https://nextjs.org/docs/messages/export-no-custom-routes`
    )
  }

  const buildId = await fs.readFile(buildIdFile, 'utf8')

  const pagesManifest =
    !options.pages &&
    (require(join(distDir, SERVER_DIRECTORY, PAGES_MANIFEST)) as PagesManifest)

  let previewProps: DeepReadonly<PreviewPropsManifest> | undefined
  try {
    previewProps = require(join(distDir, 'server', PREVIEW_PROPS_MANIFEST))
  } catch {}

  let prerenderManifest: DeepReadonly<PrerenderManifest> | undefined

View on GitHub (pinned to 258b1c1bc0)

Solutions

  1. Remove `output: "export"` if you rely on rewrites/redirects/headers, or implement them at the static host level.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/next/src/export/index.ts:250 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of vercel/next.js@258b1c1bc0 (2026-08-19). Data as JSON: /api/errors/fb4d8c8e68edbd5a. Report an issue: GitHub.