Skip to content

Commit

Permalink
Fixed content-type
Browse files Browse the repository at this point in the history
  • Loading branch information
TwoAbove committed Sep 25, 2024
1 parent 471b326 commit 81b2e08
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/patreon.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,16 @@ const loadPatreonClient = async (req, res, next) => {
if (!response.ok) {
console.error(`Patreon API error: ${response.status} ${response.statusText}`);
if (response.status === 503) {
// Service Unavailable, we might want to retry after a delay
return res.status(503).json({ error: "Patreon service temporarily unavailable" });
}
// For other errors, we'll send a generic error message
return res.status(500).json({ error: "Error fetching Patreon data" });
return res.status(response.status).json({ error: "Error fetching Patreon data" });
}

const contentType = response.headers.get("content-type");
if (!contentType || !contentType.includes("application/json")) {
// Handle non-JSON responses
if (
!contentType ||
!(contentType.includes("application/json") || contentType.includes("application/vnd.api+json"))
) {
console.error("Unexpected content type from Patreon API:", contentType);
return res.status(500).json({ error: "Unexpected response from Patreon" });
}
Expand Down

0 comments on commit 81b2e08

Please sign in to comment.