diff --git a/backend/package.json b/backend/package.json index 9045c8b..64712fc 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.19.96", + "version": "2.19.97", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/settings.js b/backend/src/restful/settings.js index fa623da..5c806de 100644 --- a/backend/src/restful/settings.js +++ b/backend/src/restful/settings.js @@ -61,7 +61,7 @@ async function updateSettings(req, res) { export async function updateAvatar() { const settings = $.read(SETTINGS_KEY); - const { githubUser: username, syncPlatform } = settings; + const { githubUser: username, syncPlatform, githubProxy } = settings; if (username) { if (syncPlatform === 'gitlab') { try { @@ -92,7 +92,9 @@ export async function updateAvatar() { try { const data = await $.http .get({ - url: `https://api.github.com/users/${encodeURIComponent( + url: `${ + githubProxy ? `${githubProxy}/` : '' + }https://api.github.com/users/${encodeURIComponent( username, )}`, headers: { diff --git a/backend/src/utils/gist.js b/backend/src/utils/gist.js index 0aeba25..0864673 100644 --- a/backend/src/utils/gist.js +++ b/backend/src/utils/gist.js @@ -9,7 +9,11 @@ import { SETTINGS_KEY } from '@/constants'; export default class Gist { constructor({ token, key, syncPlatform }) { const { isStash, isLoon, isShadowRocket, isQX } = ENV(); - const { defaultProxy, defaultTimeout: timeout } = $.read(SETTINGS_KEY); + const { + defaultProxy, + defaultTimeout: timeout, + githubProxy, + } = $.read(SETTINGS_KEY); let proxy = defaultProxy; if ($.env.isNode) { proxy = @@ -63,7 +67,9 @@ export default class Gist { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36', }; this.http = HTTP({ - baseURL: 'https://api.github.com', + baseURL: `${ + githubProxy ? `${githubProxy}/` : '' + }https://api.github.com`, headers: { ...this.headers, ...(isStash && proxy