Cloudflare Maintenance Mode
Create Worker -> "Create a Service"
Click "Quick Edit"
- Copy and paste below code block
const html = `<!DOCTYPE html>
<body>
<h1>Maintenance mode</h1>
</body>`;
async function handleRequest(request) {
return new Response(html, {
headers: {
'content-type': 'text/html;charset=UTF-8',
},
});
}
addEventListener('fetch', event => {
return event.respondWith(handleRequest(event.request));
});
(Optional) Test the code or edit by your needs
Click "Save and deploy"
Go to Dashboard. Choose your account.
Click "Workers" on the left menu. Click to your worker just created
Click "Add route" and type ".your-domain.com/" to "Route" input and choose zone/website.
Click "Add route" and done \m/
Unknown (2022-08-23 22:49:12)
#cloudflare