export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
if (url.pathname === "/status") {
let currentState = await env.MAINTENANCE_KV.get("maintenance");
return new Response(`Maintenance mode ${currentState}`, { status: 200 });
}
let maintenanceMode = await env.MAINTENANCE_KV.get("maintenance");
if (maintenanceMode === "on" || url.toString().includes("maintenance.example.com")) {
const html = <"html of the page as a string">;
return new Response(html, { status: 503, headers: {
"content-type": "text/html;charset=UTF-8",
}, });
}
return fetch(request);
},
}
export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
if (url.pathname === "/status") {
let currentState = await env.MAINTENANCE_KV.get("maintenance");
return new Response(`Maintenance mode ${currentState}`, { status: 200 });
}
let maintenanceMode = await env.MAINTENANCE_KV.get("maintenance");
if (maintenanceMode === "on" || url.toString().includes("maintenance.example.com")) {
const html = <"html of the page as a string">;
return new Response(html, { status: 503, headers: {
"content-type": "text/html;charset=UTF-8",
}, });
}
return fetch(request);
},
}