From 21cc29b3e6ae48de483f6c622529eca1e698a973 Mon Sep 17 00:00:00 2001 From: EndoNrak Date: Mon, 9 Oct 2023 15:12:38 +0900 Subject: [PATCH] fix lambda response header --- .../post_turtle_training_code/post_turtle_training_code.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cloud/sam/scripts/post_turtle_training_code/post_turtle_training_code.py b/cloud/sam/scripts/post_turtle_training_code/post_turtle_training_code.py index d293668..18d480d 100644 --- a/cloud/sam/scripts/post_turtle_training_code/post_turtle_training_code.py +++ b/cloud/sam/scripts/post_turtle_training_code/post_turtle_training_code.py @@ -34,6 +34,8 @@ def evaluation(event: dict, context): "statusCode": 200, "headers": { "Content-Type": "image/jpeg", + 'Access-Control-Allow-Origin': FRONTEND_ORIGIN, + 'Access-Control-Allow-Methods': 'OPTIONS,POST', }, "isBase64Encoded": True, "body": base64.b64encode(open('/tmp/canvas.jpg', 'rb').read()).decode('utf-8') @@ -44,6 +46,8 @@ def evaluation(event: dict, context): "body": "Time expired error", "headers": { "Content-Type": "text/plain", + 'Access-Control-Allow-Origin': FRONTEND_ORIGIN, + 'Access-Control-Allow-Methods': 'OPTIONS,POST', }, } except subprocess.CalledProcessError as e: @@ -52,6 +56,8 @@ def evaluation(event: dict, context): "body": f"Runtime error\n{e.stderr.decode('utf-8')}", "headers": { "Content-Type": "text/plain", + 'Access-Control-Allow-Origin': FRONTEND_ORIGIN, + 'Access-Control-Allow-Methods': 'OPTIONS,POST', }, }