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:
parent
0dbd8eeb77
commit
f6b171ed50
2 changed files with 14 additions and 1 deletions
5
.changeset/gorgeous-dancers-return.md
Normal file
5
.changeset/gorgeous-dancers-return.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"astro": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Respect error status when handling Actions with a progressive fallback.
|
|
@ -47,7 +47,15 @@ export const onRequest = defineMiddleware(async (context, next) => {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
Object.defineProperty(locals, '_actionsInternal', { writable: false, value: actionsInternal });
|
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) {
|
function nextWithLocalsStub(next: MiddlewareNext, locals: Locals) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue