Example for WebPDetectionLambdaFunctionARN
reipan opened this issue · comments
Hey there,
i'm pretty new to that topic. Can you give me an example of a working lambda@edge function that enables webp detection in tachyon?
This is what we are running in production:
exports.handler = (event, context, callback) => {
if (
event.Records[0].cf.request.headers['accept'] &&
event.Records[0].cf.request.headers['accept'][0].value.indexOf('image/webp') >
-1
)
event.Records[0].cf.request.headers['x-webp'] = [{key:'X-WebP', value: '1'}];
return callback(null, event.Records[0].cf.request);
};
Hope that helps!