I've seen the custom 404.astro page. But how does this translate to server-side rendering? (Using the node.js adapter if that matters.)
Looking at the Response docs, I thought about writing something like:
---
import { render } from 'astro/???'
import { getProduct } from '../api'
import { MyErrorAstroComponent } from '../MyErrorAstroComponent'
const product = await getProduct(Astro.params.id)
if (!product) {
const props = { status: 404 }
return new Response(render(MyErrorAstroComponent, props), {
status: 404
})
}
---
<html>
<!-- Success page here... -->
</html>
Same question for a 500 or 503 page, e.g. if the database times out or something...
I've found How can I render a astro component to a HTML string?, but no good answer...