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 e37102b commit b4f57e1
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 @@ -61,18 +61,16 @@ 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"

if not any(re.fullmatch(o, request.origin) for o in ALLOWED_ORIGINS):
response.status_code = 403
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 b4f57e1

Please sign in to comment.