Use Custom Domains
Use your own domain to serve the RudderStack JavaScript SDK and send events to RudderStack.
This guide covers the steps to use your own domain instead of RudderStack domains for the following use cases:
Setting up custom domains for the above use cases can help you adhere to your Content Security Policy (CSP), reduce the impact of adblockers, and satisfy any compliance-related requirements.

The steps and examples in this guide are applicable for
AWS CloudFront. However, the settings should be similar regardless of your CDN.
Setup overview

You must have access to your domain’s DNS settings and your CDN settings.
Create a new distribution by following these steps:
- Log in to your AWS console.
- Click Services and go to Network & Content Delivery > CloudFront.
- Click Create a CloudFront distribution.
The following table gives a high-level overview of the required cache policy, origin request policy, and response headers policy:
Domains to proxy

Why do I need to set up a proxy?
Setting up a proxy is not required to just solve the events delivery issue. It’s also important if you want to use server-side cookies, rely on document.referrer, or navigate through any other restrictions imposed by modern browsers.
The following table lists the three domains that you need to proxy via your own domain to successfully load the SDK and route the events to the RudderStack backend (data plane).
| Domain | Use case |
|---|
cdn.rudderlabs.com | To load the JavaScript SDK. |
api.rudderstack.com | To fetch the source configuration based on the source write key. |
DATA_PLANE_URL | To send events to RudderStack. See the Dashboard Overview guide for more information on obtaining your data plane URL. |
For each domain, you will need to create a CDN distribution and add a CNAME record in your domain for the distribution domain.

To use your own domain for the above endpoints, you will need to route the traffic through your CDN for which you will incur charges.
FAQ
Why am I seeing CORS errors after setting up custom domains?
CORS errors usually indicate misconfigured CDN distribution settings, not an SDK defect. Verify each distribution uses the origin request policies and CORS-With-Preflight response headers policy described in this guide — especially for Fetch Source Configuration and Send Events.
Confirm in the browser Network tab that SDK, source configuration, and event requests route through your custom domains.
Can I overcome ad blockers by serving the JavaScript SDK on my domain?
Many popular ad blockers block specific SDK-related downloads and API calls based on the domain name and URL. You can serve the SDK on your CDN to circumvent this issue.
Questions? We're here to help.
Join the RudderStack Slack community or email us for support