Skip to content

Commit d45e27f

Browse files
authored
Log aposResponse errors (#5386)
* log aposResponse errors * add changeset --------- Co-authored-by: Harouna Traoré <haroun@users.noreply.github.com>
1 parent 08845c5 commit d45e27f

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

.changeset/wild-lies-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@apostrophecms/apostrophe-astro": minor
3+
---
4+
5+
Log aposResponse errors

packages/apostrophe-astro/lib/aposResponse.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default async function aposResponse(req) {
4949

5050
const aposUrl = new URL(aposHost + pathname);
5151
aposUrl.search = url.search;
52-
52+
5353
// Prepare headers, excluding any specified in config
5454
const requestHeaders = {};
5555
for (const [name, value] of req.headers) {
@@ -111,6 +111,7 @@ export default async function aposResponse(req) {
111111
}
112112
// Skip unknown encodings silently
113113
} catch (decompressError) {
114+
console.error(decompressError);
114115
// If decompression fails, return original response
115116
return new Response(new Uint8Array(bodyArrayBuffer), {
116117
...rest,
@@ -133,10 +134,12 @@ export default async function aposResponse(req) {
133134
headers: responseHeaders
134135
});
135136
} catch (bodyError) {
137+
console.error(bodyError);
136138
// If we can't process the body, fall back to the original response
137139
return new Response(res.body, { ...rest, status: statusCode, headers: responseHeaders });
138140
}
139141
} catch (error) {
142+
console.error(error);
140143
// Handle any unexpected errors
141144
return new Response(`Server error: ${error.message}`, { status: 500 });
142145
}

0 commit comments

Comments
 (0)