---
title: "ServeTunnel"
description: "Serves a tunnel on your server so Sentry browser SDK events reach Sentry through your own origin, past ad blockers."
url: https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/integrations/servetunnel/
---

# ServeTunnel for Cloudflare

Available since: `v11.13.0`

*Import name: `Sentry.serveTunnelIntegration`*

This integration serves the tunnel that the browser SDK uses when you set `tunnel: true`. The tunnel forwards the browser's events to Sentry, so ad blockers don't drop them. To set it up, see [Tunneling](https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/tunneling.md).

```javascript
export default Sentry.withSentry(
  (env) => ({
    dsn: "https://<key>@o<orgId>.ingest.sentry.io/<projectId>",
    integrations: [Sentry.serveTunnelIntegration()],
  }),
  {
    async fetch(request, env, ctx) {
      // Your app
    },
  },
);
```

## [Options](https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/integrations/servetunnel.md#options)

Most apps don't need any of these options.

### [`allowedDsns`](https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/integrations/servetunnel.md#alloweddsns)

*Type: `string[]`*

DSNs to forward besides the server's own. Use this when the browser uses a different DSN than the server. The server's own DSN is always allowed.

```javascript
Sentry.serveTunnelIntegration({
  allowedDsns: ["https://<key>@o<orgId>.ingest.sentry.io/<projectId>"],
});
```

### [`path`](https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/integrations/servetunnel.md#path)

*Type: `string`*

A fixed tunnel path instead of the one derived from the DSN. The SDK doesn't add the base path it reads from your framework config, so include it in the path, or set `basePath` too. Set the same path in the browser, as described in [Using a Fixed Path](https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/tunneling.md#using-a-fixed-path).

### [`basePath`](https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/integrations/servetunnel.md#basepath)

*Type: `string`*

The path prefix your app is served under, for example `/docs`. The SDK reads it from your framework config, so you only need this option when it can't. Set the same value in the browser `tunnel` option.

### [`intercept`](https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/integrations/servetunnel.md#intercept)

*Type: `boolean`* *Default: `true`*

Whether the SDK answers tunnel requests before they reach your app. Set it to `false` to answer them from your own code with `handleTunnelRequestIfMatched`, for example behind your own middleware. Tunnel requests still don't show up in your traces:

```javascript
import express from "express";
import * as Sentry from "@sentry/node";

const app = express();

app.use(
  (req, res, next) =>
    Sentry.handleTunnelRequestIfMatched(req, res) ?? next(),
);
```

Add it before any middleware that reads the request body.
