Skip to content

Commit 376b862

Browse files
committed
fix: we should skip processing if isCloudFrontRequestValid is false
1 parent 31101ab commit 376b862

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ exports.handler = async (event, context, callback) => {
1919
const request = event.Records[0].cf.request;
2020
const response = event.Records[0].cf.response;
2121

22-
if ('200' !== response.status || isCloudFrontRequestValid(request)) {
22+
if ('200' !== response.status || !isCloudFrontRequestValid(request)) {
2323
return callback(null, response);
2424
}
2525

@@ -88,7 +88,7 @@ exports.handler = async (event, context, callback) => {
8888
* @returns {boolean} True if processing should be skipped, false otherwise
8989
*/
9090
function isCloudFrontRequestValid(request) {
91-
return !request.origin || !request.origin.s3 || !request.origin.s3.domainName;
91+
return request.origin && request.origin.s3 && request.origin.s3.domainName;
9292
}
9393

9494
/**

0 commit comments

Comments
 (0)