Fix: Use robust JSON helper for header handling

This commit is contained in:
2025-10-02 11:54:33 -07:00
parent 33c759cec7
commit daa6ec7681

View File

@@ -1,4 +1,8 @@
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 });
};
export async function onRequestPost({ request, env }) { export async function onRequestPost({ request, env }) {
try { try {