fix(build): ship src/static-content markdown in standalone output

Several entry points read markdown from src/static-content at runtime via
fs (dynamic string paths @vercel/nft cannot trace). With output: standalone
the build only ships traced files, so the markdown was missing from the
deployed image and every read hit ENOENT -> 500/404 (/safety, /content,
and the site-wide checkTosUpdate TOS check). Worked locally only because the
full source tree is present.

Add experimental.outputFileTracingIncludes keyed by every read site so the
files are force-included into the standalone bundle. On Next 14 this key
lives under experimental (top-level only takes effect in Next 15).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@
This commit is contained in:
Briant Diehl
2026-06-05 12:08:21 -06:00
parent 10ec1fa01e
commit bb605de707
+24
View File
@@ -122,6 +122,30 @@ export default defineNextConfig(
'@tabler/icons-react',
'@headlessui/react',
],
// Several entry points read markdown from src/static-content at runtime via
// fs (dynamic string paths that @vercel/nft can't trace). With
// output: 'standalone' the build only ships traced files, so without these
// explicit includes the markdown is missing in the deployed image and every
// read hits ENOENT -> 500/404 (works locally because the full source tree is
// present). Keyed by every entry point that performs the read:
// /safety, /region-blocked - direct fs read in getServerSideProps
// /content/[[...slug]] - content.get via SSG prefetch (SSR)
// /api/trpc/[trpc] - content.get + checkTosUpdate (the
// TOS check runs for every logged-in
// user on every page)
// /api/v1/content/[[...slug]] - content.get via REST apiCaller
// In standalone mode the includes are unioned into the shared .next/standalone
// root, so any one key would suffice, but we list each read site explicitly so
// the fix survives a future move off standalone (per-function tracing).
// NOTE: on Next 14 this key lives under `experimental` (moved to top-level in
// Next 15) - placing it at the top level here is a silent no-op.
outputFileTracingIncludes: {
'/safety': ['./src/static-content/**/*'],
'/region-blocked': ['./src/static-content/**/*'],
'/content/[[...slug]]': ['./src/static-content/**/*'],
'/api/trpc/[trpc]': ['./src/static-content/**/*'],
'/api/v1/content/[[...slug]]': ['./src/static-content/**/*'],
},
},
headers: async () => {
// Add X-Robots-Tag header to all pages matching /sitemap.xml and /sitemap-models.xml /sitemap-articles.xml, etc