Skip to content

Commit

Permalink
Handle errors in media requests
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas committed Mar 25, 2024
1 parent 9da3649 commit ceb8e0f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/server/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ export async function handleMedia(req: Request) {
const media = await fetch(url, {
headers: getProxySafeMediaHeaders(req),
});

if (!media.ok) {
return new Response(media.body, {
headers: { ...CORS_HEADERS },
status: media.status,
});
}

// This will include the cache control headers
const mediaHeaders = Object.fromEntries(media.headers.entries());
const responseHeaders = new Headers({ ...mediaHeaders, ...CORS_HEADERS });
Expand Down

0 comments on commit ceb8e0f

Please sign in to comment.