Perform CORS validation when the request has a cookie (#8743)

* Perform CORS validation when the request has a cookie

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Abubakar Abid 2024-07-11 06:57:48 -07:00 committed by GitHub
parent a9307c6452
commit ee497d5c3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
"gradio": minor
---
feat:Perform CORS validation when the request has a cookie

View File

@ -744,9 +744,8 @@ class CustomCORSMiddleware:
message.setdefault("headers", [])
headers = MutableHeaders(scope=message)
headers.update(self.simple_headers)
has_cookie = "cookie" in request_headers
origin = request_headers["Origin"]
if has_cookie or self.is_valid_origin(request_headers):
if self.is_valid_origin(request_headers):
self.allow_explicit_origin(headers, origin)
await send(message)