@mineko-io/lambda-edge-root-doc
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

Lambda Edge Root Doc

This 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.

Configuration

You can configure behavior of this method:

  • newUriCallback: Callback method which gets the cloudfront request object. Must return a cloudfront request object.
  • log: Enables logging to console (default: false)

Usage

How to use it:

Install

npm i -S @mineko-io/lambda-edge-root-doc

Example

Use it on your Lambda@Edge function like this:

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;
    };
})

Package Sidebar

Install

npm i @mineko-io/lambda-edge-root-doc

Weekly Downloads

0

Version

2.0.2

License

MIT

Unpacked Size

11.5 kB

Total Files

13

Last publish

Collaborators

  • mineko-smueller
  • tech-mineko-io
  • mainaero