Skip to content

Commit

Permalink
[Fix] 🐛 Cloudflare Worker SysConf API Error
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-zklcdc committed Feb 18, 2024
1 parent 254c85d commit 8a38b4a
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions cloudflare/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,12 @@ const verify = async (request, cookie) => {
const res = await fetch(newReq)
if (res.status != 200) {
if (res.status === 451) {
return new Response('{"code":451,"message":"Verification Failed","data":null}', { status: 451 })
return new Response('{"code":451,"message":"Verification Failed","data":null}', {
status: 451,
headers: new Headers({
'Content-Type': 'application/json'
})
})
}
return new Response('{"code":500,"message":"Server Error","data":null}', { status: res.status })
}
Expand All @@ -388,7 +393,12 @@ const verify = async (request, cookie) => {
*/
const pass = async (request, cookie) => {
if (request.method != 'POST') {
return new Response('{"code":405,"message":"Method Not Allowed","data":null}', { status: 405 });
return new Response('{"code":405,"message":"Method Not Allowed","data":null}', {
status: 405,
headers: new Headers({
'Content-Type': 'application/json'
})
});
}

let resqBody = JSON.parse(await request.text());
Expand Down Expand Up @@ -439,7 +449,11 @@ const login = async (url, headers) => {
* @returns
*/
const bingapi = async (request, cookie) => {
return new Response('{"code":200,"message":"TODO","data":null}')
return new Response('{"code":200,"message":"TODO","data":null}', {
headers: new Headers({
'Content-Type': 'application/json'
})
})
};

export default {
Expand All @@ -459,8 +473,12 @@ export default {
if (currentUrl.pathname === '/' || currentUrl.pathname.indexOf('/web/') === 0) {
return home(currentUrl.pathname);
}
if (currentUrl.pathname === '/sysconf') {
return new Response('{"code":200,"message":"success","data":{"isSysCK":false,"isAuth":true}}')
if (currentUrl.pathname.startsWith('/sysconf')) {
return new Response('{"code":200,"message":"success","data":{"isSysCK":false,"isAuth":true}}', {
headers: new Headers({
'Content-Type': 'application/json'
})
})
}
let targetUrl;
if (currentUrl.pathname.includes('/sydney')) {
Expand Down

0 comments on commit 8a38b4a

Please sign in to comment.