Skip to content

Commit 42c204b

Browse files
pedrosousasdnts
authored andcommitted
[Rules] Add response header accepts an expression (cloudflare#23786)
1 parent ff542a3 commit 42c204b

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/content/docs/rules/transform/response-header-modification/create-dashboard.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ To create a rule:
3131
:::
3232

3333
8. For **Modify response header**, select one of the following operations:
34-
34+
- _Add static_ — Adds an HTTP response header with a static string value. This operation will not remove any existing response headers with the same name.
35+
- _Add dynamic_ — Adds an HTTP response header according to the provided expression. This operation will not remove any existing response headers with the same name.
3536
- _Set static_ — Sets the value of an HTTP response header to a static string value. Overrides the value of any existing headers with the same name or adds a new header if it does not exist.
3637
- _Set dynamic_ — Sets the value of an HTTP response header according to the provided expression. Overrides the value of any existing headers with the same name or adds a new header if it does not exist.
37-
- _Add_ — Adds an HTTP response header with a static string value. This operation will not remove any existing response headers with the same name.
3838
- _Remove_ — Removes the HTTP response header with the provided name, if it exists.
3939

4040
9. Enter the name of the HTTP response header to modify in **Header name** and the static value or expression in **Value**, if you are setting the header value.

src/content/docs/rules/transform/response-header-modification/index.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Through Response Header Transform Rules you can:
3838
- Set the value of an HTTP response header to a literal string value, overwriting its previous value or adding a new header to the response if it does not exist.
3939
- Set the value of an HTTP response header according to an expression, overwriting its previous value or adding a new header to the response if it does not exist.
4040
- Add a new HTTP response header with a literal string value without removing any existing headers with the same name.
41+
- Add a new HTTP response header according to an expression without removing any existing headers with the same name.
4142
- Remove an HTTP header from the response.
4243

4344
You can create a response header transform rule [in the dashboard](/rules/transform/response-header-modification/create-dashboard/), [via API](/rules/transform/response-header-modification/create-api/), or [using Terraform](/terraform/additional-configurations/transform-rules/#create-a-response-header-transform-rule).
@@ -67,9 +68,7 @@ You can create a response header transform rule [in the dashboard](/rules/transf
6768

6869
- Modifying `cache-control`, `CDN-Cache-Control`, or `Cloudflare-CDN-Cache-Control` headers will not change the way Cloudflare caches an object. Instead, you should create a [Cache Rule](/cache/how-to/cache-rules/).
6970

70-
- To add a `set-cookie` header to the response, make sure you use the _Add_ operation instead of _Set static_/_Set dynamic_. Using one of the _Set_ operations will remove any `set-cookie` headers already in the response, including those added by other Cloudflare products such as Bot Management.
71-
72-
- Currently you can only use the _Add_ operation with a literal string value.
71+
- To add a `set-cookie` header to the response, make sure you use one of the _Add static_/_Add dynamic_ operations instead of _Set static_/_Set dynamic_. Using one of the _Set_ operations will remove any `set-cookie` headers already in the response, including those added by other Cloudflare products such as Bot Management.
7372

7473
<Render
7574
file="troubleshoot-rules-with-trace"

src/content/docs/rules/transform/response-header-modification/reference/parameters.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ To set an HTTP response header, overwriting any headers with the same name, use
1212

1313
- **operation**: `set`
1414
- Include one of the following parameters to define a static or dynamic value:
15-
1615
- **value**: Specifies a static value for the HTTP response header.
1716
- **expression**: Specifies the expression that defines a value for the HTTP response header.
1817

1918
To add an HTTP response header, keeping any existing headers with the same name, use the following parameters in the `action_parameters` field:
2019

2120
- **operation**: `add`
22-
- **value**: Specifies a static value for the HTTP response header.
21+
- Include one of the following parameters to define a static or dynamic value:
22+
- **value**: Specifies a static value for the HTTP response header.
23+
- **expression**: Specifies the expression that defines a value for the HTTP response header.
2324

2425
To remove an HTTP response header, set the following parameter in the `action_parameters` field:
2526

@@ -48,7 +49,7 @@ The full syntax of the `action_parameters` field to define a dynamic HTTP respon
4849
"action_parameters": {
4950
"headers": {
5051
"<HEADER_NAME>": {
51-
"operation": "set",
52+
"operation": "<set|add>",
5253
"expression": "<EXPRESSION>"
5354
}
5455
}

0 commit comments

Comments
 (0)