Will define root doc for lambda@edge based on given path
npm install @mineko-io/lambda-edge-root-docThis module provides a method to define the root document for origin requests from cloudfront in Lambda@Edge.
For each request which ends with a trailingslash / the newUriCallback gets called.
Useful method for Lambda@Edge for ReactJS applications deployed to AWS S3 with a main index.html file.
* newUriCallback: Callback method which gets the cloudfront request object. Must return a cloudfront request object.
* log: Enables logging to console (default: false)
bash
npm i -S @mineko-io/lambda-edge-root-doc
`$3
Use it on your Lambda@Edge function like this:
`ts
import DefineRootDoc from '@mineko-io/lambda-edge-root-doc';exports.handler = DefineRootDoc.getCloudfrontRequestHandler({
log: true,
newUriCallback: (request: AWSLambda.CloudFrontRequest): AWSLambda.CloudFrontRequest => {
request.uri =
${request.uri}index.html;
return request;
};
})
``