500.astro content is not showing when throwing an error from a middleware #8797
Labels
- P4: important
Violate documented behavior or significantly impacts performance (priority)
feat: error pages
Related to 404 and 500 handling (scope)
Astro Info
If this issue only occurs in one browser, which browser is a problem?
Chrome
Describe the Bug
I have a sequence of middleware, the
auth
middleware may throw an error if it is not happy with the user credentials.when the middleware or the page throws it is showing the normal browser 500 error (image below).
Note: to reporduce, please try the 'preview' command rather than 'dev' cause I noticed different behaviours sometimes.
What's the expected result?
If the middleware throws, I expect the
content
of500.astro
to appear on the page, that is the nicely designed page with the site identity.A few notes:
redirect()
to/error
, but I want the user to stay on the same url just with a nice view showing the error.I also have a few questions:
500.astro
(without using cookies, if possible)?Response
object from the first middleware, does it stop the other middlewares in the sequence?>400
responses? right now I have400, 404, 500
.astro but I would like a generalerror.astro
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-qhuzp1?file=package.json
Participation
The text was updated successfully, but these errors were encountered: