diff --git a/cloudflare/src/OPTIONS.js b/cloudflare/src/OPTIONS.js index 4d626691ea..31d6813c46 100644 --- a/cloudflare/src/OPTIONS.js +++ b/cloudflare/src/OPTIONS.js @@ -73,5 +73,5 @@ export function init_CUSTOM_OPTIONS(env) { CUSTOM_OPTIONS.Go_Proxy_BingAI_BLANK_API_KEY = (env.Go_Proxy_BingAI_BLANK_API_KEY != '' && env.Go_Proxy_BingAI_BLANK_API_KEY != undefined && env.Go_Proxy_BingAI_BLANK_API_KEY != null); CUSTOM_OPTIONS.INFO = env.INFO || ''; CUSTOM_OPTIONS.NIGHTLY = (env.NIGHTLY != '' && env.NIGHTLY != undefined && env.NIGHTLY != null); - CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY = env.Go_Proxy_BingAI_AUTH_KEY.split(",") || []; + CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY = env.Go_Proxy_BingAI_AUTH_KEY != undefined && env.Go_Proxy_BingAI_AUTH_KEY != null && env.Go_Proxy_BingAI_AUTH_KEY != '' ? env.Go_Proxy_BingAI_AUTH_KEY.split(',') : []; } diff --git a/cloudflare/src/worker.js b/cloudflare/src/worker.js index 7fbdef881f..b2e4c05cab 100644 --- a/cloudflare/src/worker.js +++ b/cloudflare/src/worker.js @@ -295,22 +295,20 @@ export async function workerFetch(request, env, ctx,home) { if (currentUrl.pathname.startsWith('/sysconf')) { let isAuth = true; - if (CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY.length !== 0) { - if (CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY[0] != '') { - const cookieStr = request.headers.get('Cookie') || ''; - let cookieObjects = {}; - cookieStr.split(';').forEach(item => { - if (!item) { - return; - } - const arr = item.split('='); - const key = arr[0].trim(); - const val = arr.slice(1, arr.length+1).join('=').trim(); - cookieObjects[key] = val; - }) - if (cookieObjects[AUTH_KEY_COOKIE_NAME] !== CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY) { - isAuth = false; + if (CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY.length > 0) { + const cookieStr = request.headers.get('Cookie') || ''; + let cookieObjects = {}; + cookieStr.split(';').forEach(item => { + if (!item) { + return; } + const arr = item.split('='); + const key = arr[0].trim(); + const val = arr.slice(1, arr.length+1).join('=').trim(); + cookieObjects[key] = val; + }) + if (cookieObjects[AUTH_KEY_COOKIE_NAME] !== CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY) { + isAuth = false; } } return Response.json({ code: 200, message: 'success', data: { isSysCK: false, isAuth: isAuth, info: CUSTOM_OPTIONS.INFO } })