From 195cbd3b641bfb336256b54005e618cd536f1d75 Mon Sep 17 00:00:00 2001 From: DefectingCat Date: Mon, 5 Sep 2022 11:32:58 +0800 Subject: [PATCH] add gists proxy url --- lib/fetcher.ts | 4 ++-- package.json | 3 +-- scripts/gists/index.mjs | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/fetcher.ts b/lib/fetcher.ts index b457600..fa1d0f5 100644 --- a/lib/fetcher.ts +++ b/lib/fetcher.ts @@ -2,10 +2,10 @@ import { Octokit } from 'octokit'; import { GistsFile } from 'types'; const password = process.env.NEXT_PUBLIC_GITHUB_API; +const host = process.env.NEXT_PUBLIC_GISTS_HOST ?? 'http://api.github.com'; const octokit = new Octokit({ auth: password, - // @TODO reverse proxy - baseUrl: 'http://api.github.com', + baseUrl: host, }); const linkMatch = /<(.*?)>/; diff --git a/package.json b/package.json index 50f340f..6fa43f9 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,7 @@ "dev": "next dev", "build": "next build && yarn build:search", "build:export": "cross-env NEXT_BUILD=export next build && cross-env NEXT_BUILD=export next export", - "build:search": "node scripts/build-search.mjs", - "build:search-g": "node scripts/build-search.mjs -g", + "build:search": "node scripts/build-search.mjs -g", "start": "next start", "lint": "next lint", "test": "jest --watch", diff --git a/scripts/gists/index.mjs b/scripts/gists/index.mjs index adda3b7..db23919 100644 --- a/scripts/gists/index.mjs +++ b/scripts/gists/index.mjs @@ -9,10 +9,10 @@ import { Octokit } from 'octokit'; */ async function getGists(page, perPage) { const password = process.env.NEXT_PUBLIC_GITHUB_API; + const host = process.env.NEXT_PUBLIC_GISTS_HOST ?? 'http://api.github.com'; const octokit = new Octokit({ auth: password, - // @TODO reverse proxy - baseUrl: 'http://api.github.com', + baseUrl: host, }); return await octokit.rest.gists.list({ page,