Set up a single AWS CloudFront distribution to reverse proxy both static assets and Guides and Surveys API traffic. This may help circumvent domain blocking in certain regions or by specific extensions and DNS servers. Guides and Surveys APIs and static assets are latency-sensitive, as a result Amplitude recommends using edge-hosted solutions to minimize round-trip time.
This setup uses one CloudFront distribution with two origins and two cache behaviors:
cdn.amplitude.com
for static SDK assets.gs.amplitude.com
or gs.eu.amplitude.com
for API requests prefixed with /sdk/
.In AWS, open CloudFront and click Create CloudFront distribution.
Configure the first origin:
cdn.amplitude.com
for the US data center, or cdn.eu.amplitude.com
for the EU data centerGET, HEAD, OPTIONS
OPTIONS
CachingOptimized
)AllViewerExceptHostHeader
CORS-with-preflight-and-SecurityHeadersPolicy
Click Create distribution
Add a second origin for the Guides and Surveys API. Navigate to the Origins tab and click Create origin:
gs.amplitude.com
for the US data center, orgs.eu.amplitude.com
for the EU data centerNavigate to the 'Behaviors' tab and click Create behavior:
/sdk/*
gs.amplitude.com
or gs.eu.amplitude.com
GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
OPTIONS
CachingDisabled
AllViewerExceptHostHeader
CORS-with-preflight-and-SecurityHeadersPolicy
After AWS deploys the distribution, test both the API and CDN paths to ensure that requests route to the correct origins.
Replace SUBDOMAIN
with the CloudFront domain name and APIKEY
with your project’s API key.
curl -i 'https://SUBDOMAIN.cloudfront.net/sdk/v1/decide' -H 'Authorization: Api-Key APIKEY'
A successful response returns HTTP status 200 OK
.
curl -I 'https://SUBDOMAIN.cloudfront.net/engagement-browser/prod/index.min.js.gz'
A successful response returns HTTP status 200 OK
.
Point both serverUrl
and cdnUrl
to the same CloudFront domain:
engagement.init("API_KEY", { serverUrl: "https://SUBDOMAIN.cloudfront.net", cdnUrl: "https://SUBDOMAIN.cloudfront.net"});
April 25th, 2025
Need help? Contact Support
Visit Amplitude.com
Have a look at the Amplitude Blog
Learn more at Amplitude Academy
© 2025 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.