Created
October 4, 2019 23:02
-
-
Save matthewberryman/433530a9413441aaf0e3013926f06f23 to your computer and use it in GitHub Desktop.
vary_headers.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// If the response lacks a Vary: header, fix it in a CloudFront Origin Response trigger. | |
exports.handler = (event, context, callback) => { | |
const response = event.Records[0].cf.response; | |
const headers = response.headers; | |
if (!headers['vary']) | |
{ | |
headers['vary'] = [ | |
{ key: 'Vary', value: 'Access-Control-Request-Headers' }, | |
{ key: 'Vary', value: 'Access-Control-Request-Method' }, | |
{ key: 'Vary', value: 'Origin' }, | |
]; | |
} | |
callback(null, response); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment