Created
March 29, 2018 16:36
-
-
Save furkan3ayraktar/1c60235c1f50f8684a21370bff78fed5 to your computer and use it in GitHub Desktop.
Detecting relevant paths in the request.
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
const path = require('path'); | |
exports.handler = (event, context, callback) => { | |
const { request, config } = event.Records[0].cf; | |
let originalUri = request.uri; | |
const parsedPath = path.parse(originalUri); | |
if (parsedPath.ext === '') { | |
// Every request that does not have an extension should be a route in our | |
// SPA. We can fetch index.html here and add proper metadata. All other | |
// requests with proper extensions should be redirected to actual resource | |
// in S3. | |
} else { | |
return callback(null, request); // Do not modify request. | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment