mirror of
https://github.com/masterking32/MasterHttpRelayVPN.git
synced 2026-05-17 21:24:37 +03:00
feat: add health check response for GET requests in Cloudflare Worker
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -46,8 +46,28 @@ function sanitizeHeaders(h) {
|
|||||||
export default {
|
export default {
|
||||||
async fetch(req) {
|
async fetch(req) {
|
||||||
try {
|
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") {
|
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();
|
const body = await req.json();
|
||||||
|
|||||||
Reference in New Issue
Block a user