Serverless Node.js examples using TypeScript are organized into groups and designed to illustrate the techniques needed to build great microservices. To use the samples clone our GitHub repository using Git.
- Checkout the code and install dependencies
sls create --template-url https://github.com/alertbox/serverless-basics-device-detect-ts --path my-basics-device-detect-svc
- Compile and run example
cd my-basics-device-detect-svc
npm start
- Play with the serverless example
We use Lambda@Edge functions to change CloudFront requests and responses before it forwards to the origin. Please see Adding CloudFront Triggers page on AWS for a comprehensive documentation about Customizing CloudFront using Lambda@Edge functions.
With VS Code:
- Open VS Code Terminal
- Build and deploy
npm run build
npm run deploy
With AWS Console:
- Login to AWS Console and go to CloudFront Console
- Go to the Edit Behavior pattern of your CloudFront Distribution
- Whitelist
CloudFront-Is-Mobile-Viewer
andOrigin
headers - Associate lambda function
basics-device-detect
ARN as theOrigin Request
event type