Question: How to handle Errors
lautiamkok opened this issue · 0 comments
lautiamkok commented
Is there any guide on how to handle errors, e.g. 500, on the server side? I still can't figure out how to do it with this plugin:
export default viteSSR(App,
{
routes
},
({ url, app, router, initialState, request, isClient, writeResponse, redirect }) => {
const head = createHead()
app.use(head)
app.config.errorHandler = (err, vm, info) => {
const statusCode = err.statusCode ? err.statusCode : 500
// Reload browser so that the error is handled on SSR instead.
if (isClient) {
location.reload()
}
if (import.meta.env.SSR) {
writeResponse({
status: statusCode,
html: err.message // how can we pass the app html here?
})
}
}
return { head }
}
)
Thanks!