Add CloudFront Function for directory index routing
- Create CloudFront Function to rewrite directory requests to index.html - Fix admin login page routing issue (/upadaj -> /upadaj/index.html) - Attach function to CloudFront distribution default cache behavior - Enables proper routing for all admin pages without .html extension
This commit is contained in:
17
terraform/cloudfront-function.js
Normal file
17
terraform/cloudfront-function.js
Normal file
@@ -0,0 +1,17 @@
|
||||
function handler(event) {
|
||||
var request = event.request;
|
||||
var uri = request.uri;
|
||||
|
||||
// Check whether the URI is missing a file extension
|
||||
if (!uri.includes('.')) {
|
||||
// Check if URI ends with /
|
||||
if (uri.endsWith('/')) {
|
||||
request.uri += 'index.html';
|
||||
} else {
|
||||
// Add /index.html to directory paths
|
||||
request.uri += '/index.html';
|
||||
}
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
Reference in New Issue
Block a user