diff options
author | Kenny Ballou <kballou@devnulllabs.io> | 2018-04-09 21:50:35 -0600 |
---|---|---|
committer | Kenny Ballou <kballou@devnulllabs.io> | 2018-08-19 11:31:21 -0600 |
commit | 655ef46f50d95209c39da1aa26a2d1c520b77193 (patch) | |
tree | 97835230a553c98a93b187acb146c6f604d97301 /stacks/uri-rewrite.in | |
parent | 23ac5f2751e92e71da00e35753259b44d1aad1ab (diff) | |
download | kennyballou.com-655ef46f50d95209c39da1aa26a2d1c520b77193.tar.gz kennyballou.com-655ef46f50d95209c39da1aa26a2d1c520b77193.tar.xz |
Add cloudformation templates and tooling
Blag will be managed using cloudfront/S3/lambdaedge, specified via
cloudformation.
Signed-off-by: Kenny Ballou <kballou@devnulllabs.io>
Diffstat (limited to 'stacks/uri-rewrite.in')
-rw-r--r-- | stacks/uri-rewrite.in | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/stacks/uri-rewrite.in b/stacks/uri-rewrite.in new file mode 100644 index 0000000..6df707c --- /dev/null +++ b/stacks/uri-rewrite.in @@ -0,0 +1,13 @@ +[+ autogen5 template -*- mode: json -*- +] +{"Fn::Join": ["\n", [ + "'use strict';", + "exports.handler = (event, context, callback) => {", + " var whitelist = ['css', 'html', 'jpg', 'svg', 'png', 'txt', 'xml', 'pdf'];", + " var request = event.Records[0].cf.request;", + " var extension = request.uri.split('.').pop();", + " if (typeof extension == 'undefined' || !whitelist.includes(extension)) {", + " request.uri = request.uri.replace(/\\\/?$/, '\/index.html');", + " }", + " return callback(null, request);", + "};" +]]} |