Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-lies-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apostrophecms/apostrophe-astro": minor
---

Log aposResponse errors
5 changes: 4 additions & 1 deletion packages/apostrophe-astro/lib/aposResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default async function aposResponse(req) {

const aposUrl = new URL(aposHost + pathname);
aposUrl.search = url.search;

// Prepare headers, excluding any specified in config
const requestHeaders = {};
for (const [name, value] of req.headers) {
Expand Down Expand Up @@ -111,6 +111,7 @@ export default async function aposResponse(req) {
}
// Skip unknown encodings silently
} catch (decompressError) {
console.error(decompressError);
// If decompression fails, return original response
return new Response(new Uint8Array(bodyArrayBuffer), {
...rest,
Expand All @@ -133,10 +134,12 @@ export default async function aposResponse(req) {
headers: responseHeaders
});
} catch (bodyError) {
console.error(bodyError);
// If we can't process the body, fall back to the original response
return new Response(res.body, { ...rest, status: statusCode, headers: responseHeaders });
}
} catch (error) {
console.error(error);
// Handle any unexpected errors
return new Response(`Server error: ${error.message}`, { status: 500 });
}
Expand Down