optimize: 检查更新和获取远程配置功能,避免被GFW拦截。
parent
1173ee9096
commit
20b21843c4
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue