Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #479 from brc-dd/master-1
Browse files Browse the repository at this point in the history
fix: enable cors for api routes
  • Loading branch information
andrewbranch authored Aug 15, 2023
2 parents cec410b + c71bd72 commit e49a4e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/functions/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { getPRInfo } from "../queries/pr-query";
const headers = {
"Content-Type": "text/json",
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Origin": "https://www.typescriptlang.org",
"Vary": "Origin"
};
const notFound = (reason: string) => ({
headers,
Expand All @@ -27,7 +28,7 @@ export async function httpTrigger(request: HttpRequest, context: InvocationConte
// Extract the JSON from the comment
const jsonText = welcomeComment.body.replace(/^[^]*```json\n([^]*)\n```[^]*$/, "$1");
const response = { title: prInfo.title, ...JSON.parse(jsonText) };
return { status: 200, body: JSON.stringify(response) };
return { headers, status: 200, body: JSON.stringify(response) };
}
// Allow all others to access this, we can
// tighten this down to the TS URLs if the route is abused
Expand Down
2 changes: 1 addition & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const start = async function () {
console.error(` No PR with this number exists, (${JSON.stringify(info)})`);
continue;
}
let state: BotResult | undefined
let state: BotResult | undefined;
try {
state = await deriveStateForPR(prInfo);
}
Expand Down

0 comments on commit e49a4e1

Please sign in to comment.