From f1162abadb36057b07c50cf6266beceeaed349b8 Mon Sep 17 00:00:00 2001 From: Rohan Weeden Date: Tue, 19 Mar 2024 15:02:48 -0400 Subject: [PATCH] Add debug logging --- thin_egress_app/app.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/thin_egress_app/app.py b/thin_egress_app/app.py index a8db5c48..59434e28 100644 --- a/thin_egress_app/app.py +++ b/thin_egress_app/app.py @@ -458,6 +458,7 @@ def is_cors_allowed(): origin_header = app.current_request.headers.get("origin") cors_origin = os.getenv("CORS_ORIGIN") + log.debug("origin_header: %r, cors_origin: %r", origin_header, cors_origin) return bool( origin_header and cors_origin @@ -881,17 +882,23 @@ def dynamic_url_options(): "Access-Control-Request-Method", "", ).strip() + log.info("Received CORS preflight request for method: %r", request_method) + + log.debug("is_cors_allowed: %s", is_cors_allowed()) + log.debug("request_method in allowed_methods: %s", request_method in allowed_methods) if is_cors_allowed() and request_method in allowed_methods: headers = { "Access-Control-Allow-Methods": ", ".join(allowed_methods) } add_cors_headers(headers) + log.info("Returning success response") return Response( body="", headers=headers, status_code=204, ) + log.info("Returning error response") return Response( body="Method Not Allowed", status_code=405,