Skip to content

Commit e5c59c7

Browse files
committed
Add CORS preflight handling for OPTIONS requests in Envoy configuration
1 parent d7f16d1 commit e5c59c7

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

charts/synapse/scripts/envoy.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,30 @@ static_resources:
5757
- name: local_service
5858
domains: ["*"]
5959
routes:
60+
# CORS preflight — intercept all OPTIONS requests, no upstream proxy
61+
- match:
62+
prefix: "/"
63+
headers:
64+
- name: ":method"
65+
exact_match: "OPTIONS"
66+
direct_response:
67+
status: 204
68+
response_headers_to_add:
69+
- header:
70+
key: "access-control-allow-origin"
71+
value: "*"
72+
- header:
73+
key: "access-control-allow-methods"
74+
value: "GET, HEAD, POST, PUT, DELETE, OPTIONS"
75+
- header:
76+
key: "access-control-allow-headers"
77+
value: "X-Requested-With, Content-Type, Authorization, Date"
78+
- header:
79+
key: "access-control-expose-headers"
80+
value: "Synapse-Trace-Id, Server"
81+
- header:
82+
key: "content-length"
83+
value: "0"
6084
- match:
6185
safe_regex:
6286
regex: '^/_matrix/client/(api/v1|r0|v3|unstable)/(sync|events|initialSync|rooms/[^/]+/initialSync)(?:\?.*)?$'

0 commit comments

Comments
 (0)