2.0.2 • Published 4 years ago

@mineko-io/lambda-edge-root-doc v2.0.2

Weekly downloads
31
License
MIT
Repository
github
Last release
4 years ago

Lambda Edge Root Doc

npm.io

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

4 years ago

2.0.0

4 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago