@@ -91,6 +91,10 @@ def lambda_handler(event, context):
9191 except (KeyError , json .JSONDecodeError , ValueError , TypeError ) as e :
9292 return {
9393 'statusCode' : 400 ,
94+ 'headers' : {
95+ 'Access-Control-Allow-Origin' : '*' ,
96+ 'Access-Control-Allow-Methods' : '*' ,
97+ },
9498 'body' : json .dumps ({
9599 'message' : 'Invalid input data' ,
96100 'error' : str (e )
@@ -101,6 +105,10 @@ def lambda_handler(event, context):
101105 if not all (k in question for k in ('QuestionText' , 'Options' , 'CorrectAnswer' , 'Trivia' )):
102106 return {
103107 'statusCode' : 400 ,
108+ 'headers' : {
109+ 'Access-Control-Allow-Origin' : '*' ,
110+ 'Access-Control-Allow-Methods' : '*' ,
111+ },
104112 'body' : json .dumps ({
105113 'message' : 'Each question must contain QuestionText, Options, CorrectAnswer, and Trivia'
106114 })
@@ -138,6 +146,10 @@ def lambda_handler(event, context):
138146 print (f"Failed to publish to SNS: { sns_e } " )
139147 return {
140148 'statusCode' : 500 ,
149+ 'headers' : {
150+ 'Access-Control-Allow-Origin' : '*' ,
151+ 'Access-Control-Allow-Methods' : '*' ,
152+ },
141153 'body' : json .dumps ({
142154 'message' : 'Error storing quiz data. It has been queued for retry.' ,
143155 'error' : str (e )
@@ -146,5 +158,9 @@ def lambda_handler(event, context):
146158
147159 return {
148160 'statusCode' : 200 ,
161+ 'headers' : {
162+ 'Access-Control-Allow-Origin' : '*' ,
163+ 'Access-Control-Allow-Methods' : '*' ,
164+ },
149165 'body' : json .dumps ({'QuizID' : quiz_id })
150166 }
0 commit comments