you just need to implement CORS correctly. you aren't even handling the CORS preflight request so of
you just need to implement CORS correctly. you aren't even handling the CORS preflight request so of course it won't work
headers is always going to be blank other than pix-api in that scenario.headers with let headers = new Headers(); which is an empty object and then only contains the pix-api header which you set.ctx.req.headers
const enableCORS = (request, response) => {
const origin = request.headers.get("origin") || "";
const isAllowedOrigin =
origin === "http://localhost:3000" ||
origin.endsWith(".example.com");
if (isAllowedOrigin) {
for (const [key, value] of Object.entries({
"Access-Control-Allow-Origin": origin,
"Access-Control-Allow-Methods": "POST, DELETE, GET, OPTIONS",
"Access-Control-Allow-Headers": "*",
})) {
response.headers.append(key, value);
}
}
return response;
};if (request.method === "OPTIONS") {
return new Response("ok");
}const response = await handleRequest(request, env, context, sentry);
return enableCORS(request, response);