---
title: Proxy Feature Flag SDK Traffic
description: >-
  Route Datadog Feature Flag SDK network requests through a proxy on your own
  domain.
breadcrumbs: Docs > Feature Flags > Feature Flags Guides > Proxy Feature Flag SDK Traffic
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Proxy Feature Flag SDK Traffic

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Overview{% #overview %}

The Datadog Feature Flag SDK makes two types of outbound network requests from your application:

1. **Flag configuration download**: The SDK fetches precomputed flag assignments from the Datadog CDN at startup and when the evaluation context changes. This request determines which flag variants are returned to your application.
1. **Event uploads**: The SDK sends exposure and evaluation event data to Datadog intake endpoints.

You can route either or both of these request types through a proxy on your own domain. Common reasons to use a proxy include:

- Network policies that restrict direct access to third-party domains from client devices
- Data residency or compliance requirements
- Ad-blocker avoidance for browser applications

{% alert level="info" %}
The code samples on this page use the US1 site (`datadoghq.com`) as an example. Replace the Datadog domains with the corresponding values for your [Datadog site](https://docs.datadoghq.com/getting_started/site.md).
{% /alert %}

## Configure the proxy{% #configure-the-proxy %}

{% tab title="Android" %}
Pass custom endpoint URLs to `FlagsConfiguration.Builder` before calling `Flags.enable()`.

### Flag configuration proxy{% #flag-configuration-proxy %}

To route the flag configuration download through your proxy, call `useCustomFlagEndpoint` with the full URL your proxy exposes. The SDK sends a POST request to this URL with the evaluation context in the body.

In the `Application.kt` file:

```kotlin
import com.datadog.android.flags.FlagsConfiguration

val flagsConfig = FlagsConfiguration.Builder()
    .useCustomFlagEndpoint("https://proxy.example.com/precompute-assignments")
    .build()

Flags.enable(flagsConfig)
```

Your proxy must forward this request to the Datadog CDN: `https://preview.ff-cdn.datadoghq.com/precompute-assignments` (replace the subdomain as needed for your [Datadog site](https://docs.datadoghq.com/getting_started/site.md)). Pass through the request body and all headers unchanged.

### Event upload proxy{% #event-upload-proxy %}

To route exposure and evaluation event uploads through your proxy, call the corresponding builder methods with the full URL of your proxy endpoint.

In the `Application.kt` file:

```kotlin
import com.datadog.android.flags.FlagsConfiguration

val flagsConfig = FlagsConfiguration.Builder()
    .useCustomFlagEndpoint("https://proxy.example.com/precompute-assignments")
    .useCustomExposureEndpoint("https://proxy.example.com/api/v2/exposures")
    .useCustomEvaluationEndpoint("https://proxy.example.com/api/v2/flagevaluation")
    .build()

Flags.enable(flagsConfig)
```

Your proxy must forward each request to the corresponding Datadog intake endpoint for your [Datadog site](https://docs.datadoghq.com/getting_started/site.md) (the following table uses the US1 site as an example):

| Proxy path               | Forward to                                        |
| ------------------------ | ------------------------------------------------- |
| `/api/v2/exposures`      | `https://api.datadoghq.com/api/v2/exposures`      |
| `/api/v2/flagevaluation` | `https://api.datadoghq.com/api/v2/flagevaluation` |

{% /tab %}

{% tab title="iOS" %}
Set custom endpoint URLs on `Flags.Configuration` before calling `Flags.enable(with:)`.

### Flag configuration proxy{% #flag-configuration-proxy %}

To route the flag configuration download through your proxy, set `customFlagsEndpoint` to the full URL your proxy exposes. The SDK sends a POST request to this URL with the evaluation context in the body.

In the `AppDelegate.swift` file:

```swift
import DatadogFlags

let flagsConfig = Flags.Configuration(
    customFlagsEndpoint: URL(string: "https://proxy.example.com/precompute-assignments")
)

Flags.enable(with: flagsConfig)
```

Your proxy must forward this request to the Datadog CDN: `https://preview.ff-cdn.datadoghq.com/precompute-assignments` (replace the subdomain as needed for your [Datadog site](https://docs.datadoghq.com/getting_started/site.md)). Pass through the request body and all headers unchanged.

To attach additional HTTP headers to flag configuration requests (for example, for authentication at your proxy), set `customFlagsHeaders`.

In the `AppDelegate.swift` file:

```swift
let flagsConfig = Flags.Configuration(
    customFlagsEndpoint: URL(string: "https://proxy.example.com/precompute-assignments"),
    customFlagsHeaders: ["X-Proxy-Token": "<YOUR_PROXY_TOKEN>"]
)
```

### Event upload proxy{% #event-upload-proxy %}

To route exposure and evaluation event uploads through your proxy, set `customExposureEndpoint` and `customEvaluationEndpoint`.

In the `AppDelegate.swift` file:

```swift
let flagsConfig = Flags.Configuration(
    customFlagsEndpoint: URL(string: "https://proxy.example.com/precompute-assignments"),
    customExposureEndpoint: URL(string: "https://proxy.example.com/api/v2/exposures"),
    customEvaluationEndpoint: URL(string: "https://proxy.example.com/api/v2/flagevaluation")
)

Flags.enable(with: flagsConfig)
```

Your proxy must forward each request to the corresponding Datadog intake endpoint for your [Datadog site](https://docs.datadoghq.com/getting_started/site.md) (the following table uses the US1 site as an example):

| Proxy path               | Forward to                                        |
| ------------------------ | ------------------------------------------------- |
| `/api/v2/exposures`      | `https://api.datadoghq.com/api/v2/exposures`      |
| `/api/v2/flagevaluation` | `https://api.datadoghq.com/api/v2/flagevaluation` |

{% /tab %}

{% tab title="React Native" %}
Pass a `FlagsConfiguration` object to `DdFlags.enable()`.

### Flag configuration proxy{% #flag-configuration-proxy %}

To route the flag configuration download through your proxy, set `customFlagsEndpoint` to the base URL of your proxy. The SDK appends `/precompute-assignments` to this value automatically and sends a POST request with the evaluation context in the body.

In the `App.tsx` file:

```typescript
import { DdFlags } from '@datadog/mobile-react-native';

await DdFlags.enable({
    customFlagsEndpoint: 'https://proxy.example.com',
    // SDK sends POST to: https://proxy.example.com/precompute-assignments
});
```

Your proxy must forward this request to the Datadog CDN: `https://preview.ff-cdn.datadoghq.com/precompute-assignments` (replace the subdomain as needed for your [Datadog site](https://docs.datadoghq.com/getting_started/site.md)). Pass through the request body and all headers unchanged.

### Event upload proxy{% #event-upload-proxy %}

To route exposure event uploads through your proxy, set `customExposureEndpoint` to the base URL of your proxy. The SDK appends `/api/v2/exposures` to this value automatically.

In the `App.tsx` file:

```typescript
await DdFlags.enable({
    customFlagsEndpoint: 'https://proxy.example.com',
    customExposureEndpoint: 'https://proxy.example.com',
    // SDK sends POST to: https://proxy.example.com/api/v2/exposures
});
```

Your proxy must forward exposure requests to the corresponding Datadog intake endpoint for your [Datadog site](https://docs.datadoghq.com/getting_started/site.md); for example, for the US1 site use `https://api.datadoghq.com/api/v2/exposures`.

{% alert level="info" %}
The React Native SDK does not expose a `customEvaluationEndpoint` option. Evaluation events are sent through the underlying native Android or iOS SDK and cannot be routed through a custom proxy endpoint.
{% /alert %}

{% /tab %}

{% tab title="Browser" %}
Pass configuration options to `DatadogBrowserFlagging.init()`.

### Flag configuration proxy{% #flag-configuration-proxy %}

To route the flag configuration download through your proxy, set `flaggingProxy` to the URL of your proxy endpoint. The SDK sends a POST request with the evaluation context in the body directly to this URL, replacing the default Datadog CDN endpoint.

In the `index.js` file:

```javascript
import { DatadogBrowserFlagging } from '@datadog/browser-flagging';

DatadogBrowserFlagging.init({
    clientToken: '<CLIENT_TOKEN>',
    site: 'datadoghq.com',
    flaggingProxy: 'https://proxy.example.com/precompute-assignments',
});
```

Your proxy must forward this request to the Datadog CDN: `https://preview.ff-cdn.datadoghq.com/precompute-assignments` (replace the subdomain as needed for your [Datadog site](https://docs.datadoghq.com/getting_started/site.md)). Pass through the request body and headers unchanged. The SDK includes `dd-client-token` and `dd-application-id` headers automatically.

To add custom headers to the flag configuration request (for example, for authentication at your proxy), use `customHeaders`:

In the `index.js` file:

```javascript
DatadogBrowserFlagging.init({
    clientToken: '<CLIENT_TOKEN>',
    site: 'datadoghq.com',
    flaggingProxy: 'https://proxy.example.com/precompute-assignments',
    customHeaders: { 'X-Proxy-Token': '<YOUR_PROXY_TOKEN>' },
});
```

### Event upload proxy{% #event-upload-proxy %}

Browser flag event data (exposures and evaluations) is sent through the standard Browser SDK intake pipeline. To route this traffic through a proxy, set the `proxy` option to a URL on your domain.

In the `index.js` file:

```javascript
DatadogBrowserFlagging.init({
    clientToken: '<CLIENT_TOKEN>',
    site: 'datadoghq.com',
    flaggingProxy: 'https://proxy.example.com/precompute-assignments',
    proxy: 'https://proxy.example.com/intake',
});
```

The SDK appends a `ddforward` query parameter to each request sent to your proxy. This parameter contains the URL-encoded path and query string that your proxy must forward to. For example:

```
POST https://proxy.example.com/intake?ddforward=%2Fapi%2Fv2%2Fexposures%3Fddsource%3Dbrowser...
```

Your proxy decodes the `ddforward` value and constructs the Datadog intake URL:

```
https://browser-intake-datadoghq.com/api/v2/exposures?ddsource=browser...
```

The intake origin varies by [Datadog site](https://docs.datadoghq.com/getting_started/site.md). For example, for `datadoghq.eu` it is `https://browser-intake-datadoghq.eu`. Forward the POST body unchanged and add an `X-Forwarded-For` header with the client IP for accurate geolocation. Remove any sensitive headers such as `cookie` before forwarding.

The `proxy` option also accepts a function that receives the decoded `path` and `parameters` and returns the full proxy URL. See [Proxy Browser RUM Data](https://docs.datadoghq.com/real_user_monitoring/guide/proxy-rum-data.md) for the full function signature.
{% /tab %}

## Further reading{% #further-reading %}

Additional helpful documentation, links, and articles:

- [Set Up a Proxy Server for Feature Flag SDK Traffic](https://docs.datadoghq.com/feature_flags/guide/proxy_server_setup.md)
- [Client-Side Feature Flags](https://docs.datadoghq.com/feature_flags/client.md)
- [Proxy Browser RUM Data](https://docs.datadoghq.com/real_user_monitoring/guide/proxy-rum-data.md)
