Skip to main content
This guide uses AWS CloudFront as a CDN/proxy layer with Route53 for DNS. This approach is ideal if you’re already running infrastructure on AWS.

Prerequisites

  • An AWS account with access to CloudFront and Route53
  • A domain with DNS managed by Route53 (or ability to point external DNS to CloudFront)
  • Basic familiarity with AWS console

Architecture Overview

Extension → CloudFront Distribution → Composite API

            Route53 DNS
CloudFront acts as a reverse proxy, forwarding requests from /analytics/* to Composite’s API while your main site continues to work normally.

Setup Guide

1

Create a CloudFront distribution

  1. Open the CloudFront console
  2. Click Create distribution
  3. Configure the origin:
    • Origin domain: prod.alb.us.api.composite.com
    • Protocol: HTTPS only
    • HTTPS port: 443
    • Name: composite-analytics-origin
  4. Under Default cache behavior:
    • Viewer protocol policy: Redirect HTTP to HTTPS
    • Allowed HTTP methods: GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
    • Cache policy: CachingDisabled
    • Origin request policy: AllViewerExceptHostHeader
  5. Click Create distribution
2

Add a behavior for /analytics path

After the distribution is created:
  1. Go to the Behaviors tab
  2. Click Create behavior
  3. Configure:
    • Path pattern: /analytics/*
    • Origin: Select your composite-analytics-origin
    • Viewer protocol policy: Redirect HTTP to HTTPS
    • Allowed HTTP methods: GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
    • Cache policy: CachingDisabled
    • Origin request policy: AllViewerExceptHostHeader
  4. Click Create behavior
You must use CachingDisabled for the cache policy. Caching API responses will cause data loss and incorrect analytics.
3

Configure Route53 DNS

  1. Open Route53 console
  2. Go to Hosted zones → Select your domain
  3. Click Create record
  4. Configure:
    • Record name: Leave empty for root domain
    • Record type: A
    • Alias: Yes
    • Route traffic to: Alias to CloudFront distribution
    • Choose distribution: Select your distribution
  5. Click Create records
DNS propagation typically takes a few minutes but can take up to 48 hours in rare cases.
4

Configure your SDK

Update your extension to use the custom endpoint:
await composite.init({
  apiKey: 'pk_your_api_key',
  apiHost: 'https://yourdomain.com/analytics',
  transport: 'chrome-extension'
});
Update your manifest:
"host_permissions": [
  "https://yourdomain.com/*"
]

Test Your Distribution

Before configuring your SDK, verify CloudFront is routing requests correctly:
  1. Find your CloudFront distribution domain in the General tab (e.g., d1234abcd.cloudfront.net)
  2. Test the analytics endpoint:
    https://d1234abcd.cloudfront.net/analytics/health
    
  3. You should see a response from the Composite API
Once DNS is configured, test with your actual domain:
https://yourdomain.com/analytics/health

Troubleshooting

This usually means CloudFront cannot reach the origin:
  1. Verify the origin domain is correct: prod.alb.us.api.composite.com
  2. Ensure HTTPS is enabled on the origin settings
  3. Check that the origin request policy is AllViewerExceptHostHeader
Check your CloudFront behavior configuration:
  1. Verify the path pattern is /analytics/*
  2. Ensure the origin is set to prod.alb.us.api.composite.com
  3. Check that the behavior is using the correct origin
CloudFront should pass through CORS headers from the origin. If you’re still seeing errors:
  1. Create a CloudFront response headers policy with CORS settings
  2. Attach it to your /analytics/* behavior

What’s Next?