fix: reponse headers are immutable

This commit is contained in:
Julien Oculi 2024-06-04 17:47:38 +02:00
parent d8bfc6ca0c
commit 8fff67d358

View file

@ -27,12 +27,13 @@ Deno.serve({ port: Number(Deno.env.get('PORT') ?? 8000) }, async (req) => {
if (response.ok) {
// Update content-type if not bin file
if (response.headers.get('Content-Type') !== 'application/octet-stream') {
response.headers.set('Content-Type', mimeType)
const headers = new Headers(response.headers)
if (headers.get('Content-Type') !== 'application/octet-stream') {
headers.set('Content-Type', mimeType)
}
// Stream original file to user
return response
return new Response(response.body, { headers })
}
return response