no, for now I only use Get, post
no, for now I only use Get, post
OPTIONS request, which fails.
OPTIONS request, irrespective of your Access-Control-Allow-Methods. If you don't handle that in your Worker, then the entire thing fails

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);OPTIONSOPTIONSAccess-Control-Allow-Methods