From 90bf81a04bf6da736e334737c3f69029fed3cd91 Mon Sep 17 00:00:00 2001 From: geftactics Date: Fri, 2 Feb 2024 11:01:33 +0000 Subject: [PATCH] Redirect URI without trailing slash Fixes an issue where URI without trailing slash causes HTML assets to fail to load. 302 redirect appending a trailing slash fixes. --- url-rewrite-single-page-apps/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/url-rewrite-single-page-apps/index.js b/url-rewrite-single-page-apps/index.js index 7033d21..f50ea86 100644 --- a/url-rewrite-single-page-apps/index.js +++ b/url-rewrite-single-page-apps/index.js @@ -8,8 +8,15 @@ function handler(event) { } // Check whether the URI is missing a file extension. else if (!uri.includes('.')) { - request.uri += '/index.html'; + var response = { + statusCode: 302, + statusDescription: 'Moved Permanently', + headers: { + 'location': { value: uri + '/' } + } + }; + return response; } return request; -} \ No newline at end of file +}