Skip to content

Commit

Permalink
workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewquang512 committed Dec 16, 2023
1 parent 728065e commit a4d9ac6
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,28 @@ export const handler = startServerAndCreateLambdaHandler(
async (event) => {
console.log('###? received event=' + JSON.stringify(event));
},
async (event, lambdaContext, callback) => {
// Handle CORS preflight request
if (event.httpMethod === 'OPTIONS') {
const response = {
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true,
'Access-Control-Allow-Methods': 'OPTIONS, POST, GET',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
},
body: '',
};
return callback(null, response);
}

// Handle regular requests
return callback(null);
},
],
cors: {
origin: '*',
credentials: true,
},
},
);

0 comments on commit a4d9ac6

Please sign in to comment.