Skip to content

Commit

Permalink
[Fix] 🐛 Cloudflare Deploy Error
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-zklcdc committed Jun 15, 2024
1 parent cc06850 commit 6f47d60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cloudflare/src/OPTIONS.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(',') : [];
}
28 changes: 13 additions & 15 deletions cloudflare/src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } })
Expand Down

0 comments on commit 6f47d60

Please sign in to comment.