-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use HTTP 404 & forward Cache-Control, Content-Type, Expires, and Last-Modified headers from S3. #158
Use HTTP 404 & forward Cache-Control, Content-Type, Expires, and Last-Modified headers from S3. #158
Changes from all commits
088a5b9
5eb5c87
03a6e5b
8393774
8d7e2a5
592cd16
74de982
502e1a0
1176fd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,14 @@ exports.handler = async (event) => { | |
const request = await imageRequest.setup(event); | ||
console.log(request); | ||
const processedRequest = await imageHandler.process(request); | ||
const headers = getResponseHeaders(); | ||
headers["Content-Type"] = request.ContentType; | ||
headers["Expires"] = request.Expires; | ||
headers["Last-Modified"] = request.LastModified; | ||
headers["Cache-Control"] = request.CacheControl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to supply overridden values? In the base64 encoded string There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, @bretto36. I'm not using either of those features (changing formats or base64), but I'll take a look when I get a chance. |
||
const response = { | ||
"statusCode": 200, | ||
"headers" : getResponseHeaders(), | ||
"headers" : headers, | ||
"body": processedRequest, | ||
"isBase64Encoded": true | ||
} | ||
|
@@ -51,8 +56,7 @@ const getResponseHeaders = (isErr) => { | |
const headers = { | ||
"Access-Control-Allow-Methods": "GET", | ||
"Access-Control-Allow-Headers": "Content-Type, Authorization", | ||
"Access-Control-Allow-Credentials": true, | ||
"Content-Type": "image" | ||
"Access-Control-Allow-Credentials": true | ||
} | ||
if (corsEnabled) { | ||
headers["Access-Control-Allow-Origin"] = process.env.CORS_ORIGIN; | ||
|
@@ -61,4 +65,4 @@ const getResponseHeaders = (isErr) => { | |
headers["Content-Type"] = "application/json" | ||
} | ||
return headers; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you are changing the image from a jpg to a png.
If i put
'toFormat' => 'png'
in my image settings but the source is a jpeg this will output image/jpg