---
title: Proxy Your Browser RUM Data
description: >-
  Configure browser RUM data proxying with SDK source options and
  version-specific settings for custom network routing.
breadcrumbs: >-
  Docs > RUM & Session Replay > Real User Monitoring & Session Replay Guides >
  Proxy Your Browser RUM Data
---

# Proxy Your Browser RUM Data

{% section displayed-if="SDK version is <4.34.0" %}
This section only applies to users who meet the following criteria: SDK version is <4.34.0

{% alert level="danger" %}
Upgrade to Browser SDK `4.34.0` or later to avoid security vulnerabilities in your proxy configuration.
{% /alert %}
{% /section %}

## Overview{% #overview %}

The RUM Browser SDK can be configured to send requests through a proxy. When you set the SDK's `proxy` [initialization parameter](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/browser/setup/client/?tab=rum#initialization-parameters) to a URL such as `https://www.example-proxy.com/any-endpoint`, all RUM data is sent to that URL using the POST method. The RUM data still needs to be forwarded to Datadog from the proxy.

## Prerequisite proxy setup{% #prerequisite-proxy-setup %}

To successfully forward a request to Datadog, your proxy must

1. Build the Datadog intake URL.
1. Add an `X-Forwarded-For` header containing the request client IP address for accurate geoIP.
1. Forward the request to the Datadog intake URL using the POST method.
1. Leave the request body unchanged.

{% alert level="warning" %}

- For security reasons, remove any HTTP headers that potentially contain sensitive information, such as the `cookie` header.
- The request body can contain binary data and should not be converted to a string. Make sure your proxy implementation forwards the raw body without conversion.
- Make sure your proxy implementation does not allow a malicious actor to send requests to a different server. For example: `https://browser-intake-datadoghq.com.malicious.com`.

{% /alert %}

### Build the Datadog intake URL{% #build-the-datadog-intake-url %}

Your Datadog intake URL should have the format `<INTAKE_ORIGIN>/<PATH><PARAMETERS>` (for example, `https://browser-intake-datadoghq.eu/api/v2/rum?ddsource=browser&...`).

| intake origin | The Datadog intake origin corresponds to your `site` [initialization parameter](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/browser/setup/client/?tab=rum#initialization-parameters). The Datadog intake origin corresponding to your site parameter should be defined in your proxy implementation.
Important note for users on the following Datadog sites: app.datadoghq.com: 
The intake origin for your Datadog site is `https://browser-intake-datadoghq.com`.
Important note for users on the following Datadog sites: us3.datadoghq.com: 
The intake origin for your Datadog site is `https://browser-intake-us3-datadoghq.com`.
Important note for users on the following Datadog sites: us5.datadoghq.com: 
The intake origin for your Datadog site is `https://browser-intake-us5-datadoghq.com`.
Important note for users on the following Datadog sites: app.datadoghq.eu: 
The intake origin for your Datadog site is `https://browser-intake-datadoghq.eu`.
Important note for users on the following Datadog sites: ap1.datadoghq.com: 
The intake origin for your Datadog site is `https://browser-intake-ap1-datadoghq.com`.
Important note for users on the following Datadog sites: ap2.datadoghq.com: 
The intake origin for your Datadog site is `https://browser-intake-ap2-datadoghq.com`.
Important note for users on the following Datadog sites: app.ddog-gov.com: 
The intake origin for your Datadog site is `https://browser-intake-ddog-gov.com`. |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| path          | The path contains the API version and the product (for example, `/api/v2/rum` for RUM data or `/api/v2/replay` for Session Replay data).

The path for each request can be accessed in the request's `ddforward` parameter (for example, `https://www.example-proxy.com/any-endpoint?ddforward=%2Fapi%2Fv2%2Frum%3Fddsource%3Dbrowser`).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| parameters    | The request parameters (for example, `ddsource=browser&...`) can be accessed in the request's `ddforward` parameter (for example, `https://www.example-proxy.com/any-endpoint?ddforward=%2Fapi%2Fv2%2Frum%3Fddsource%3Dbrowser`).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

## SDK setup{% #sdk-setup %}

{% section
   displayed-if="The selected value for SDK version is included in the given list: '>=5.4.0, >=4.34.0'" %}
This section only applies to users who meet the following criteria: The selected value for SDK version is included in the given list: '>=5.4.0, >=4.34.0'

Configure the URL of the proxy in the `proxy` initialization parameter:

{% section displayed-if="SDK source is NPM" %}
This section only applies to users who meet the following criteria: SDK source is NPM

```
import { Datacenter, datadogRum } from '@datadog/browser-rum';

datadogRum.init({
    applicationId: '<DATADOG_APPLICATION_ID>',
    clientToken: '<DATADOG_CLIENT_TOKEN>',
    site: '',
    proxy: '<YOUR_PROXY_URL>',
});
```
{% /section %}

{% section displayed-if="SDK source is CDN async" %}
This section only applies to users who meet the following criteria: SDK source is CDN async

```
window.DD_RUM.onReady(function() {
    window.DD_RUM.init({
        clientToken: '<CLIENT_TOKEN>',
        applicationId: '<APPLICATION_ID>',
        proxy: '<YOUR_PROXY_URL>',
    });
});
```
{% /section %}

{% section displayed-if="SDK source is CDN sync" %}
This section only applies to users who meet the following criteria: SDK source is CDN sync

```
window.DD_RUM &&
    window.DD_RUM.init({
        clientToken: '<CLIENT_TOKEN>',
        applicationId: '<APPLICATION_ID>',
        proxy: '<YOUR_PROXY_URL>'
    });
```
{% /section %}

The RUM Browser SDK adds a `ddforward` query parameter to all requests to your proxy. This query parameter contains the URL path and parameters that all data must be forwarded to.

For example, with a `site` set to `datadoghq.eu` and a `proxy` set to `https://example.org/datadog-intake-proxy`, the RUM Browser SDK sends requests to a URL like this: `https://example.org/datadog-intake-proxy?ddforward=%2Fapi%2Fv2%2Frum%3Fddsource%3Dbrowser`. The proxy forwards the request to `https://browser-intake-datadoghq.eu/api/v2/rum?ddsource=browser`.

{% section displayed-if="SDK version is >=5.4.0" %}
This section only applies to users who meet the following criteria: SDK version is >=5.4.0

### Passing a function to the `proxy` initialization parameter{% #passing-a-function-to-the- %}

The `proxy` initialization parameter also supports a function input. This function allows you to have more control on how the path and parameters are added to the proxy URL.

This function receives an object with the following properties:

- `path`: the path for the Datadog requests (example: `/api/v2/rum`)
- `parameters`: the parameters of the Datadog requests (example: `ddsource=browser&...`)

{% section displayed-if="SDK source is NPM" %}
This section only applies to users who meet the following criteria: SDK source is NPM

```
import { Datacenter, datadogRum } from '@datadog/browser-rum';

datadogRum.init({
    applicationId: '<DATADOG_APPLICATION_ID>',
    clientToken: '<DATADOG_CLIENT_TOKEN>',
    site: '',
    proxy: (options) => `https://www.proxy.com/foo${options.path}/bar?${options.parameters}`,
});
```
{% /section %}

{% section displayed-if="SDK source is CDN async" %}
This section only applies to users who meet the following criteria: SDK source is CDN async

```
window.DD_RUM.onReady(function() {
    window.DD_RUM.init({
        clientToken: '<CLIENT_TOKEN>',
        applicationId: '<APPLICATION_ID>',
        proxy: (options) => `https://www.proxy.com/foo${options.path}/bar?${options.parameters}`,
    })
})
```
{% /section %}

{% section displayed-if="SDK source is CDN sync" %}
This section only applies to users who meet the following criteria: SDK source is CDN sync

```
window.DD_RUM &&
    window.DD_RUM.init({
        clientToken: '<CLIENT_TOKEN>',
        applicationId: '<APPLICATION_ID>',
        proxy: (options) => `https://www.proxy.com/foo${options.path}/bar?${options.parameters}`
    });
```
{% /section %}

**Note:**

- Some privacy blockers already target the intake [URL patterns](https://github.com/easylist/easylist/blob/997fb6533c719a015c21723b34e0cedefcc0d83d/easyprivacy/easyprivacy_general.txt#L3840), so you may want to take that into account when building your proxy URL.
- The `proxy` function is called for each request, so it should avoid any heavy computation.
- **JSP web applications** need to use the `\` escape character to properly propagate these parameters to the browser. For example:
  ```
  proxy: (options) => 'http://proxyURL:proxyPort\${options.path}?\${options.parameters}',
  ```
{% /section %}
{% /section %}

{% section displayed-if="SDK version is <4.34.0" %}
This section only applies to users who meet the following criteria: SDK version is <4.34.0

Before Browser SDK v4.34.0, the `proxyUrl` initialization parameter was used, and the Datadog intake origin was included in the `ddforward` attribute. The proxy implementation was in charge of validating this host, and failure to do so resulted in various vulnerabilities.

The Datadog intake origin needs to be defined in your proxy implementation to ensure security.

**To avoid security vulnerabilities, you must upgrade to Browser SDK `4.34.0` or later.**
{% /section %}

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

- [Learn about Real User Monitoring](https://docs.datadoghq.com/real_user_monitoring/)
