From 39b3e4efa2833fd4c952e71abffe85f226b2ec3e Mon Sep 17 00:00:00 2001 From: Abolfazl Date: Sat, 2 May 2026 12:27:26 +0330 Subject: [PATCH] feat: add health check response for GET requests in Cloudflare Worker Co-authored-by: Copilot --- apps_script/cloudflare_worker.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/apps_script/cloudflare_worker.js b/apps_script/cloudflare_worker.js index 27374dd..db3762c 100644 --- a/apps_script/cloudflare_worker.js +++ b/apps_script/cloudflare_worker.js @@ -46,8 +46,28 @@ function sanitizeHeaders(h) { export default { async fetch(req) { try { + // Cloudflare dashboard and browsers commonly test a Worker with GET. + // Return a friendly health response so users don't misread it as failure. + if (req.method === "GET") { + return Response.json( + { + ok: true, + status: "healthy", + message: "Everything is OK. Worker is deployed and reachable.", + usage: "Send POST with relay payload for actual proxy requests.", + }, + { status: 200 } + ); + } + if (req.method !== "POST") { - return Response.json({ e: "method_not_allowed" }, { status: 405 }); + return Response.json( + { + e: "method_not_allowed", + message: "Use POST for relay requests. GET is only a health check.", + }, + { status: 405 } + ); } const body = await req.json();