Skip to content

Commit 32599b9

Browse files
authored
[Rules] Add example for subrequests from other zones (#23065)
1 parent 2008c0a commit 32599b9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
pcx_content_type: example
3+
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

Comments
 (0)