Skip to content

Commit 6f47d60

Browse files
committed
[Fix] 🐛 Cloudflare Deploy Error
1 parent cc06850 commit 6f47d60

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

cloudflare/src/OPTIONS.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ export function init_CUSTOM_OPTIONS(env) {
7373
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);
7474
CUSTOM_OPTIONS.INFO = env.INFO || '';
7575
CUSTOM_OPTIONS.NIGHTLY = (env.NIGHTLY != '' && env.NIGHTLY != undefined && env.NIGHTLY != null);
76-
CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY = env.Go_Proxy_BingAI_AUTH_KEY.split(",") || [];
76+
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(',') : [];
7777
}

cloudflare/src/worker.js

+13-15
Original file line numberDiff line numberDiff line change
@@ -295,22 +295,20 @@ export async function workerFetch(request, env, ctx,home) {
295295

296296
if (currentUrl.pathname.startsWith('/sysconf')) {
297297
let isAuth = true;
298-
if (CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY.length !== 0) {
299-
if (CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY[0] != '') {
300-
const cookieStr = request.headers.get('Cookie') || '';
301-
let cookieObjects = {};
302-
cookieStr.split(';').forEach(item => {
303-
if (!item) {
304-
return;
305-
}
306-
const arr = item.split('=');
307-
const key = arr[0].trim();
308-
const val = arr.slice(1, arr.length+1).join('=').trim();
309-
cookieObjects[key] = val;
310-
})
311-
if (cookieObjects[AUTH_KEY_COOKIE_NAME] !== CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY) {
312-
isAuth = false;
298+
if (CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY.length > 0) {
299+
const cookieStr = request.headers.get('Cookie') || '';
300+
let cookieObjects = {};
301+
cookieStr.split(';').forEach(item => {
302+
if (!item) {
303+
return;
313304
}
305+
const arr = item.split('=');
306+
const key = arr[0].trim();
307+
const val = arr.slice(1, arr.length+1).join('=').trim();
308+
cookieObjects[key] = val;
309+
})
310+
if (cookieObjects[AUTH_KEY_COOKIE_NAME] !== CUSTOM_OPTIONS.Go_Proxy_BingAI_AUTH_KEY) {
311+
isAuth = false;
314312
}
315313
}
316314
return Response.json({ code: 200, message: 'success', data: { isSysCK: false, isAuth: isAuth, info: CUSTOM_OPTIONS.INFO } })

0 commit comments

Comments
 (0)