Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Include access-control-allow-credentials in the simple CORS flow (#12038)

Patryk Zawadzkida65c262b97e
diff --git a/saleor/asgi/cors_handler.py b/saleor/asgi/cors_handler.py
index 44b75f0b4b..c6b07bf9db 100644
--- a/saleor/asgi/cors_handler.py
+++ b/saleor/asgi/cors_handler.py
@@ -74,8 +74,16 @@ def cors_handler(application: ASGI3Application) -> ASGI3Application:
response_headers = [
(key, value)
for key, value in message["headers"]
- if key.lower() not in {b"access-control-allow-origin", b"vary"}
+ if key.lower()
+ not in {
+ b"access-control-allow-credentials",
+ b"access-control-allow-origin",
+ b"vary",
+ }
]
+ response_headers.append(
+ (b"access-control-allow-credentials", b"true")
+ )
vary_header = next(
(
value
diff --git a/saleor/asgi/tests/test_cors.py b/saleor/asgi/tests/test_cors.py
index 8fb7012c27..9898c26c20 100644
--- a/saleor/asgi/tests/test_cors.py
+++ b/saleor/asgi/tests/test_cors.py
@@ -86,6 +86,7 @@ async def test_access_control_header_simple(asgi_app: ASGI3Application, settings
type="http.response.start",
status=200,
headers=[
+ (b"access-control-allow-credentials", b"true"),
(b"access-control-allow-origin", b"http://localhost:3000"),
(b"content-type", b"text/plain"),
(b"vary", b"Origin"),