Skip to content

Commit f6b171e

Browse files
authoredMay 20, 2024··
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>
1 parent 0dbd8ee commit f6b171e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎.changeset/gorgeous-dancers-return.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"astro": patch
3+
---
4+
5+
Respect error status when handling Actions with a progressive fallback.

‎packages/astro/src/actions/runtime/middleware.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@ export const onRequest = defineMiddleware(async (context, next) => {
4747
},
4848
};
4949
Object.defineProperty(locals, '_actionsInternal', { writable: false, value: actionsInternal });
50-
return next();
50+
const response = await next();
51+
if (result.error) {
52+
return new Response(response.body, {
53+
status: result.error.status,
54+
statusText: result.error.name,
55+
headers: response.headers,
56+
})
57+
}
58+
return response;
5159
});
5260

5361
function nextWithLocalsStub(next: MiddlewareNext, locals: Locals) {

0 commit comments

Comments
 (0)
Please sign in to comment.