mirror of
				https://github.com/tormachris/cf-workers-status-page.git
				synced 2025-11-04 04:46:24 +01:00 
			
		
		
		
	PoP location detection
This commit is contained in:
		@@ -64,10 +64,11 @@ export async function processCronTrigger(event) {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // save last check timestamp including PoP location
 | 
			
		||||
  const res = await fetch("https://www.cloudflare.com/cdn-cgi/trace")
 | 
			
		||||
  const resText = await res.text()
 | 
			
		||||
  const loc = /loc=([\w]{2})/.exec(resText)[1]
 | 
			
		||||
  await setKV('lastUpdate', Date.now(), {loc})
 | 
			
		||||
  const res = await fetch('https://cloudflare-dns.com/dns-query', {
 | 
			
		||||
    method: 'OPTIONS',
 | 
			
		||||
  })
 | 
			
		||||
  const loc = res.headers.get('cf-ray').split('-')[1]
 | 
			
		||||
  await setKV('lastUpdate', Date.now(), { loc })
 | 
			
		||||
 | 
			
		||||
  // gc monitor statuses
 | 
			
		||||
  event.waitUntil(gcMonitors(config))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user