You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
summary: Create a request header transform rule to add an HTTP header when the Workers subrequest comes from a different zone.
4
+
products:
5
+
- Transform Rules
6
+
operation:
7
+
- Request modification
8
+
title: Add a request header for subrequests from other zones
9
+
description: Create a request header transform rule to add an HTTP header when the Workers subrequest comes from a different zone.
10
+
---
11
+
12
+
import { Example } from"~/components";
13
+
14
+
The following request header transform rule adds an HTTP header to Workers subrequests coming from a different zone:
15
+
16
+
<Example>
17
+
18
+
Text in **Expression Editor** (replace `myappexample.com` with your domain):
19
+
20
+
```txt
21
+
(cf.worker.upstream_zone != "" and cf.worker.upstream_zone != "myappexample.com")
22
+
```
23
+
24
+
Selected operation under **Modify request header**: _Set static_
25
+
26
+
**Header name**: `X-External-Workers-Subrequest`
27
+
28
+
**Value**: `1`
29
+
30
+
</Example>
31
+
32
+
The [`cf.worker.upstream_zone`](/ruleset-engine/rules-language/fields/reference/cf.worker.upstream_zone/) field used in the rule expression is set to empty if the current request is not a Workers subrequest.
0 commit comments