Fix: Use robust JSON helper for header handling

This commit is contained in:
2025-10-02 11:54:20 -07:00
parent 3a289190ae
commit 935c297e71

View File

@@ -1,4 +1,8 @@
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 onRequestGet({ request, env }) {
try {