Skip to content

Commit

Permalink
fix: Vary header and specific allow origin
Browse files Browse the repository at this point in the history
  • Loading branch information
frederik-encord committed Dec 19, 2024
1 parent c9460a0 commit fd019d9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions encord_agents/gcp/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ def context_wrapper_inner(func: AgentFunction) -> Callable[[Request], Response]:

@wraps(func)
def wrapper(request: Request) -> Response:
# Set CORS headers for the preflight request
if request.method == "OPTIONS":
# Allows GET requests from any origin with the Content-Type
# header and caches preflight response for an 3600s
response = make_response("")
response.headers["Vary"] = "Origin"

origin_ok = False
for origin in ALLOWED_ORIGINS:
Expand All @@ -77,7 +75,7 @@ def wrapper(request: Request) -> Response:
return response

headers = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Origin": request.origin,
"Access-Control-Allow-Methods": "POST",
"Access-Control-Allow-Headers": "Content-Type",
"Access-Control-Max-Age": "3600",
Expand Down

0 comments on commit fd019d9

Please sign in to comment.