From 90cef98b38b8fb330056c405135e7e8675d135d7 Mon Sep 17 00:00:00 2001 From: Seokyun Ha Date: Sun, 8 Oct 2023 17:50:29 +0900 Subject: [PATCH] CORS and github API response (#5) * cors * return res.data * update cors list * update cors list --- src/github/github.controller.ts | 20 ++++++++++++-------- src/main.ts | 8 +++++++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/github/github.controller.ts b/src/github/github.controller.ts index c714ae6..4c2d658 100644 --- a/src/github/github.controller.ts +++ b/src/github/github.controller.ts @@ -10,26 +10,30 @@ export class GithubController { gh_token = process.env.GITHUB_TOKEN; @Get() - getOrganizationInfo() { + async getOrganizationInfo() { const octokit = new Octokit({ auth: this.gh_token }); - return octokit.request('GET /orgs/poapper'); + const res = await octokit.request('GET /orgs/poapper'); + return res.data; } @Get('member') - getGithubMembers() { + async getGithubMembers() { const octokit = new Octokit({ auth: this.gh_token }); - return octokit.request('GET /orgs/poapper/public_members'); + const res = await octokit.request('GET /orgs/poapper/public_members'); + return res.data; } @Get('repo') - getGithubRepositories() { + async getGithubRepositories() { const octokit = new Octokit({ auth: this.gh_token }); - return octokit.request('GET /orgs/poapper/repos'); + const res = await octokit.request('GET /orgs/poapper/repos'); + return res.data; } @Get('event') - getGithubEvent() { + async getGithubEvent() { const octokit = new Octokit({ auth: this.gh_token }); - return octokit.request('GET /orgs/poapper/events?per_page=10'); + const res = await octokit.request('GET /orgs/poapper/events?per_page=10'); + return res.data; } } diff --git a/src/main.ts b/src/main.ts index 3f36ab9..b6cb1a8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,7 +8,13 @@ async function bootstrap() { app.use(cookieParser()); app.enableCors({ - origin: ['http://localhost:8000'], + origin: [ + 'http://localhost:8000', + 'http://localhost:9000', + 'http://localhost:9001', + 'https://poapper.club', + 'https://dev.poapper.club', + ], credentials: true, });