ci: prerender against the internal mesh API + fail loud if empty
All checks were successful
deploy / Build api + worker (static musl) (push) Successful in 6m11s
deploy / Build prerendered web (push) Successful in 7m28s
deploy / Deploy web to oolon (push) Successful in 55s
deploy / Deploy moments-api to nikola (push) Successful in 59s
deploy / Deploy moments-worker to frootmig (push) Successful in 1m1s
All checks were successful
deploy / Build api + worker (static musl) (push) Successful in 6m11s
deploy / Build prerendered web (push) Successful in 7m28s
deploy / Deploy web to oolon (push) Successful in 55s
deploy / Deploy moments-api to nikola (push) Successful in 59s
deploy / Deploy moments-worker to frootmig (push) Successful in 1m1s
The fedora-44 runner reaches the public internet (the CV gist on api.github.com prerendered fine) but not the public rob.tn — split-horizon DNS — so every moments-API-sourced route baked empty loading states while the build still "succeeded". prefetchQuery swallows fetch errors, so the empty snapshot shipped silently. - Point VITE_API_BASE at the internal API the deploy already reaches (http://nikola.kosherinata.internal:42424/v1), verified reachable over the mesh. Only affects the SSR/prerender build; the browser bundle still uses the relative /api/v1. - run-prerender.mjs now aborts (exit 1) if zero dynamic routes are enumerated, i.e. the API was unreachable — so an empty snapshot can never deploy again. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X7zF7Kf4JqDwa6M8Qgge9M
This commit is contained in:
@@ -81,6 +81,22 @@ function outPathFor(route) {
|
||||
const template = await readFile(join(distDir, 'index.html'), 'utf8');
|
||||
let routes = await collectRoutes();
|
||||
|
||||
// Guard: the dynamic routes (blog posts, projects) are enumerated from the
|
||||
// moments API. If none came back, the API was unreachable at build time — fail
|
||||
// loudly rather than bake and deploy an empty, content-free snapshot. (The CV,
|
||||
// sourced from the public GitHub gist, can still succeed independently.)
|
||||
const dynamicRouteCount = routes.filter(
|
||||
(r) => r.startsWith('/project/') || r.startsWith('/blog/'),
|
||||
).length;
|
||||
if (dynamicRouteCount === 0) {
|
||||
console.error(
|
||||
'prerender: 0 dynamic routes enumerated — the moments API was unreachable ' +
|
||||
'at build time. Aborting so an empty snapshot is never deployed. ' +
|
||||
`(VITE_API_BASE=${process.env.VITE_API_BASE ?? '(unset)'})`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Optional filter args: `node run-prerender.mjs /activity /cv` bakes only the
|
||||
// routes whose path starts with one of the given prefixes (useful for quick
|
||||
// iteration). With no args, every route is baked.
|
||||
|
||||
Reference in New Issue
Block a user