Skip to content

Commit

Permalink
chore: add setting of headers for bucket response
Browse files Browse the repository at this point in the history
  • Loading branch information
khuezy committed Dec 5, 2022
1 parent e88ff05 commit 45dda8f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion assets/lambda/ImageOptimization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ const requestHandler =
throw new Error(`Could not fetch image ${trimmedKey} from bucket.`)
}
pipeRes(response.Body, res)

// Respect the bucket file's content-type and cache-control
// nextImageOptimizer will use this to set the results.maxAge
if (response.ContentType) {
res.setHeader('Content-Type', response.ContentType)
}
if (response.CacheControl) {
res.setHeader('Cache-Control', response.CacheControl)
}
}
}

Expand Down

0 comments on commit 45dda8f

Please sign in to comment.