Skip to content

Commit e9090dd

Browse files
committed
add cors and responseHeaders
1 parent 16cafab commit e9090dd

4 files changed

Lines changed: 69 additions & 0 deletions

File tree

docs/configuration/cors.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: CORS
3+
---
4+
5+
# CORS
6+
7+
Configure CORS headers via the `settings.access.cors` setting.
8+
9+
**Example:**
10+
11+
```yaml
12+
settings:
13+
access:
14+
cors:
15+
methods: [GET, POST, PUT, PATCH, DELETE, OPTIONS]
16+
headers:
17+
["Content-Type", "Authorization", "Accept", "Accept-Language", "Origin"]
18+
origins:
19+
- url: "https://domain.com"
20+
- url: "https://example.com/path"
21+
methods: [GET]
22+
headers: ["Content-Type"]
23+
```
24+
25+
> [!NOTE]
26+
> The `Access-Control-Allow-Credentials` header is automatically set to `true`
27+
28+
**Defaults** can be set under `cors.methods` and `cors.headers`, when adding origins under `cors.origins` **overwrites** can be defined
29+
under `methods` and `headers` like in the example above.
30+
31+
> [!IMPORTANT]
32+
> The `cors.methods` setting maps to `Access-Control-Allow-Methods` and `cors.headers` to `Access-Control-Allow-Headers`

docs/configuration/examples/config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ api:
1717
methods: [body, query]
1818

1919
settings:
20+
http:
21+
responseHeaders:
22+
X-Custom: "xyz"
23+
2024
message:
2125
templating:
2226
messageTemplate: |
@@ -69,3 +73,11 @@ settings:
6973
- value: "+12340000[4-9]"
7074
matchType: regex
7175
action: block
76+
77+
cors:
78+
methods: [GET, POST]
79+
headers: ["Content-Type", "Accept-Language"]
80+
origins:
81+
- url: "https://domain.com"
82+
methods: [GET]
83+
headers: ["Content-Type"]

docs/configuration/examples/token.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ api:
1111
methods: [bearer, basic, body, path] # add path auth
1212

1313
settings:
14+
http:
15+
responseHeaders: # overwrite response headers
16+
X-Custom: "Lorem Ipsum Dolor"
17+
1418
message:
1519
template: # disable
1620
variables: # overwrite main config variables
@@ -39,3 +43,5 @@ settings:
3943
period: 10h # overwrite main config period
4044

4145
fieldPolicies: # disable
46+
47+
cors: # disable

docs/configuration/http.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: HTTP
3+
---
4+
5+
# HTTP
6+
7+
The `settings.http` setting is used for configuring various http-specific features.
8+
9+
**Example:**
10+
11+
```yaml
12+
settings:
13+
responseHeaders:
14+
X-Custom-Header: "xyz"
15+
```
16+
17+
## `responseHeaders`
18+
19+
Used for setting custom response headers.

0 commit comments

Comments
 (0)