HelixEvo
CDCloudflare Developers
•Created by HelixEvo on 2/14/2024 in #general-help
Cloudflare Pages With Worker Re-Direction Origin Down
I have a pages project that I wish to display if my origin is down... I have a worker setup with the following code:
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const originUrl = 'https://x.x.io/panel';
try { // Try to fetch from the origin server const response = await fetch(originUrl); // If the origin server is not down, return the response return response; } catch (err) { // If there's an error (e.g., the origin server is down), // fetch from the backup source return fetch('https://cloudflare-x.dev/'); } }
try { // Try to fetch from the origin server const response = await fetch(originUrl); // If the origin server is not down, return the response return response; } catch (err) { // If there's an error (e.g., the origin server is down), // fetch from the backup source return fetch('https://cloudflare-x.dev/'); } }
32 replies
CDCloudflare Developers
•Created by HelixEvo on 6/19/2023 in #general-help
Loadbalancer Maintenance/Holding Page
Looking for a way for the Cloudflare Loadbalancer to somehow display a maintenance page if all origins are down.. I know about the fallback pool, but wondering if there is a worker of some kind that will host the small site within Cloudflare until origins are back online.
1 replies