Skip to content

Commit

Permalink
fix(fern-bot): relax cors (#1571)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Oct 1, 2024
1 parent 36adac2 commit bfcd624
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions servers/fern-bot/src/libs/handler-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@ export const handlerWrapper =
try {
const response = await handlerFunction(event, context);

return { statusCode: 200, body: JSON.stringify(response) };
return {
statusCode: 200,
body: JSON.stringify(response),
headers: {
"Access-Control-Allow-Origin": "*", // Required for CORS support to work
"Access-Control-Allow-Credentials": true, // Required for cookies, authorization headers with HTTPS
},
};
} catch (err) {
if (err instanceof Error) {
console.error(err);
return { statusCode: 500, body: err.message };
}

return { statusCode: 500, body: "Unexpected Error" };
return {
statusCode: 500,
body: "Unexpected Error",
headers: {
"Access-Control-Allow-Origin": "*", // Required for CORS support to work
"Access-Control-Allow-Credentials": true, // Required for cookies, authorization headers with HTTPS
},
};
}
};

0 comments on commit bfcd624

Please sign in to comment.