fix(core): error 500 when no 404.html is found

This commit is contained in:
Ayo 2023-10-22 00:51:22 +02:00
parent 3ea1ed8bff
commit 9c2e0cfed6

View file

@ -10,20 +10,27 @@ export function defineRoute({ config, storage }) {
const { components: componentType } = config();
let html = await getHtml(path, storage);
const transforms = [doSetUp, deleteServerScripts];
if (html) {
const transforms = [doSetUp, deleteServerScripts];
for (const transform of transforms) {
html = transform(html.toString());
}
}
html = await useFragments(html.toString(), storage);
if (!!componentType && !!html) {
html = await insertRegistry(html.toString(), componentType, storage);
}
}
return html ?? new Response("Not found", { status: 404 });
return (
html ??
new Response(
"😱 ERROR 404: Not found. You can put a 404.html on the ./pages directory to customize this error page.",
{ status: 404 }
)
);
});
}