docs/solutions/runtime-errors/2026-05-26-registry-api-routes-need-output-file-tracing-for-source-backed-code-tabs.md
The registry source route powers lazy code-tab hydration for docs and block viewers. In a standalone Next production build, that route needs explicit output tracing for the source files it reads dynamically.
Without the include, local dev still works, but deployed /api/registry-source/[name] responses can fail when getRegistryItem() tries to read files that were not bundled.
BlockViewer has enough prefetched data for the initial file, then calls /api/registry-source/[name] for full highlighted source.apps/www/src/app/api/registry-source/[name]/route.ts calls getRegistryItem(name) and highlightFiles(item.files).getRegistryItem() resolves dependencies and calls fs.readFile(...) against src/registry/**./docs/[[...slug]] and /cn/docs/[[...slug]] need registry files for MDX-rendered previews, but the source route is a separate runtime entry.dynamic = 'force-static'. Static generation still needs the files that the route's code reads while generating JSON.Keep an explicit tracing include for the registry source route in apps/www/next.config.ts:
outputFileTracingIncludes: {
'/api/registry-source/[name]': ['./src/registry/**/*', './public/r/**/*'],
'/cn/docs/[[...slug]]': ['./src/registry/**/*', './public/r/**/*'],
'/docs/[[...slug]]': ['./src/registry/**/*', './public/r/**/*'],
}
That include belongs next to the docs route includes because they all consume the same source-backed registry graph.
Next output file tracing follows static imports, but getRegistryItem() builds file paths from registry metadata and reads them through fs. Those paths are data-driven, so the standalone bundle needs an explicit include.
/api/registry-source/[name] is the route that hydrates non-initial code-tab files. Bundling src/registry/** for docs pages alone does not cover that API entry.
outputFileTracingIncludes, search for every runtime route that calls getRegistryItem() or reads registry files:rg -n "getRegistryItem\\(|fs\\.readFile|src/registry" apps/www/src apps/www/scripts
/api/registry-source/[name], /docs/[[...slug]], and /cn/docs/[[...slug]] tracing aligned unless a route no longer reads registry source.next.config.ts tracing assertions or review checks for production bundle coverage.