Skip to content

Instantly share code, notes, and snippets.

View jackbenny's full-sized avatar
🤓
Hacking away

Jack-Benny Persson jackbenny

🤓
Hacking away
View GitHub Profile
'use strict';
const pointsToFile = uri => /\/[^/]+\.[^/]+$/.test(uri);
exports.handler = (event, context, callback) => {
// Extract the request from the CloudFront event that is sent to Lambda@Edge
var request = event.Records[0].cf.request;
// Extract the URI from the request
@jackbenny
jackbenny / lambda-redirect-to-trailing-slash.js
Created September 24, 2021 13:33 — forked from nabilfreeman/lambda-redirect-to-trailing-slash.js
Redirect to trailing slashes on CloudFront with AWS Lambda. (all this because S3 uses 302 redirects instead of 301)
'use strict';
const path = require('path')
exports.handler = (event, context, callback) => {
//get request object
const { request } = event.Records[0].cf
const url = request.uri;