0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-17 22:44:24 -05:00

fix: set status on error with progressive fallback (#11054)

* fix: set status on error with progressive fallback

* chore: changeset

* fix: obscure statusText in prod

* refactor: use error.name for statusText

---------

Co-authored-by: bholmesdev <bholmesdev@gmail.com>
This commit is contained in:
Ben Holmes 2024-05-20 15:57:56 -04:00 committed by GitHub
parent 0dbd8eeb77
commit f6b171ed50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
"astro": patch
---
Respect error status when handling Actions with a progressive fallback.

View file

@ -47,7 +47,15 @@ export const onRequest = defineMiddleware(async (context, next) => {
},
};
Object.defineProperty(locals, '_actionsInternal', { writable: false, value: actionsInternal });
return next();
const response = await next();
if (result.error) {
return new Response(response.body, {
status: result.error.status,
statusText: result.error.name,
headers: response.headers,
})
}
return response;
});
function nextWithLocalsStub(next: MiddlewareNext, locals: Locals) {