From 20b21843c403ced759c6d2045e3e46b164bc4cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Thu, 15 Aug 2024 10:51:11 +0800 Subject: [PATCH] =?UTF-8?q?optimize:=20=E6=A3=80=E6=9F=A5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=92=8C=E8=8E=B7=E5=8F=96=E8=BF=9C=E7=A8=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8A=9F=E8=83=BD=EF=BC=8C=E9=81=BF=E5=85=8D=E8=A2=AB?= =?UTF-8?q?GFW=E6=8B=A6=E6=88=AA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/config.js | 7 ++++++- packages/gui/src/bridge/update/backend.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/core/src/config.js b/packages/core/src/config.js index cb8dd6a5..ff0f35d5 100644 --- a/packages/core/src/config.js +++ b/packages/core/src/config.js @@ -59,7 +59,12 @@ const configApi = { // eslint-disable-next-line handle-callback-err return new Promise((resolve, reject) => { log.info('开始下载远程配置:', remoteConfigUrl) - request(remoteConfigUrl, (error, response, body) => { + + const headers = {} + if (remoteConfigUrl.startsWith('https://raw.githubusercontent.com/')) { + headers['Server-Name'] = 'baidu.com' + } + request(remoteConfigUrl, headers, (error, response, body) => { if (error) { log.error('下载远程配置失败, error:', error, ', response:', response, ', body:', body) reject(error) diff --git a/packages/gui/src/bridge/update/backend.js b/packages/gui/src/bridge/update/backend.js index d3822943..bd5b680c 100644 --- a/packages/gui/src/bridge/update/backend.js +++ b/packages/gui/src/bridge/update/backend.js @@ -141,7 +141,7 @@ function updateHandle (app, api, win, beforeQuit, quit, log) { // 检查更新 const releasesApiUrl = 'https://api.github.com/repos/docmirror/dev-sidecar/releases' async function checkForUpdatesFromGitHub () { - request(releasesApiUrl, { headers: { 'User-Agent': 'DS/' + curVersion } }, (error, response, body) => { + request(releasesApiUrl, { headers: { 'User-Agent': 'DS/' + curVersion, 'Server-Name': 'baidu.com' } }, (error, response, body) => { try { if (error) { log.error('检查更新失败:', error)