Skip to content

Commit cfbc937

Browse files
thomasahleclaude
andcommitted
fix: ignore 404s for image files during SSR prerendering
Lesson HTML embeds <img src="waves.png"> relative URLs. Vite rewrites these client-side but not during SSR prerendering, so the crawler reports a 404. Add handleHttpError to suppress errors for image assets. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1bbda18 commit cfbc937

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

svelte.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ const base = rawBase.endsWith('/') ? rawBase.slice(0, -1) : rawBase;
66
export default {
77
kit: {
88
adapter: adapter({ fallback: '404.html' }),
9-
paths: { base }
9+
paths: { base },
10+
prerender: {
11+
// Lesson HTML embeds <img src="waves.png"> which Vite rewrites client-side
12+
// but not during SSR prerendering — the crawler sees the original relative
13+
// URL and gets a 404. Ignore those so the build doesn't fail.
14+
handleHttpError: ({ path, referrer, message }) => {
15+
if (/\.(png|jpg|jpeg|gif|svg|webp)$/.test(path)) return;
16+
throw new Error(message);
17+
}
18+
}
1019
}
1120
};

0 commit comments

Comments
 (0)