mirror of
https://github.com/spchcap/speech.capital.git
synced 2026-01-14 16:48:44 +00:00
Fix: Use robust JSON helper for header handling
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
const json = (d, o) => new Response(JSON.stringify(d), { ...o, headers: { 'Content-Type': 'application/json', ...(o?.headers || {}) } });
|
||||
const json = (d, o = {}) => {
|
||||
const h = new Headers(o.headers);
|
||||
h.set('Content-Type', 'application/json');
|
||||
return new Response(JSON.stringify(d), { ...o, headers: h });
|
||||
};
|
||||
const cookie = c => (c.match(/auth_user=([^;]+)/)?.[1] || null);
|
||||
const hash = c => (c.match(/auth_hash=([^;]+)/)?.[1] || null);
|
||||
const tsEq=(a,b)=>{if(!a||!b)return!1;let d=a.length^b.length;for(let i=0;i<a.length;i++)d|=a.charCodeAt(i)^b.charCodeAt(i);return d===0};
|
||||
const clear = ()=>{const o=`Domain=.speech.capital; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT`;return {'Set-Cookie':`auth_user=; ${o}`,'Set-Cookie':`auth_hash=; ${o}`}};
|
||||
const clear = ()=>{const o=`Domain=.speech.capital; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT`;const h=new Headers();h.append('Set-Cookie',`auth_user=; ${o}`);h.append('Set-Cookie',`auth_hash=; ${o}`);return h};
|
||||
|
||||
export async function onRequest({ request, env }) {
|
||||
const c = request.headers.get('Cookie') || '';
|
||||
|
||||
Reference in New Issue
Block a user