From 33c759cec7591f90293d0be5fbab8030803b51da Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Thu, 2 Oct 2025 11:54:25 -0700 Subject: [PATCH] Fix: Use robust JSON helper for header handling --- functions/api/schema.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/api/schema.js b/functions/api/schema.js index b55591d..6d28d29 100644 --- a/functions/api/schema.js +++ b/functions/api/schema.js @@ -55,7 +55,11 @@ const schemaV1 = [ `CREATE UNIQUE INDEX IF NOT EXISTS idx_user_post_vote ON votes(user_id, post_id) WHERE post_id IS NOT NULL;`, `CREATE UNIQUE INDEX IF NOT EXISTS idx_user_comment_vote ON votes(user_id, comment_id) WHERE comment_id IS NOT NULL;` ]; -const json=(d,o)=>new Response(JSON.stringify(d),{...o,headers:{'Content-Type':'application/json'}}); +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 }); +}; export async function onRequestPost({ request, env }) { try {