Skip to content

Instantly share code, notes, and snippets.


Hieu Vu hieu-e

View GitHub Profile
hieu-e / CloudFrontRedirectForSPA.js
Created Dec 13, 2021
CloudFront Functions redirect for React/SPA app under subdirectory.
View CloudFrontRedirectForSPA.js
function handler(event) {
var request = event.request;
var uri = request.uri;
// Check if SPA App 1 Direcotry
if (uri.startsWith('/my-app-1')) {
request.uri = '/my-app-1/index.html';
// Check whether the URI is missing a file name.
else if(uri.endsWith('/')) {