Skip to content

Commit

Permalink
optimize: 检查更新和获取远程配置功能,避免被GFW拦截。
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Aug 15, 2024
1 parent 1173ee9 commit 20b2184
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/core/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/gui/src/bridge/update/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 20b2184

Please sign in to comment.