MichaelM
09/06/2021, 10:37 PMjohn.spurlock
09/06/2021, 10:43 PMaa
09/06/2021, 10:49 PMhannes
09/07/2021, 8:17 AMalbert
09/07/2021, 9:28 AMfetch('https://1.1.1.1/cdn-cgi/trace')
inside the DO 🙂hannes
09/07/2021, 9:30 AMlukeed
09/07/2021, 8:23 PMraRaRa
09/07/2021, 9:21 PMlukeed
09/07/2021, 9:26 PMjustinc
09/07/2021, 10:05 PMAlec
09/07/2021, 10:24 PMjustinc
09/07/2021, 10:25 PMjustinc
09/07/2021, 10:26 PMjustinc
09/07/2021, 10:27 PMjustinc
09/07/2021, 10:27 PMVanessa🦩
09/07/2021, 10:31 PMjustinc
09/07/2021, 10:33 PMVanessa🦩
09/07/2021, 10:33 PMjustinc
09/07/2021, 10:35 PMjustinc
09/07/2021, 10:37 PMVanessa🦩
09/07/2021, 10:44 PMjustinc
09/07/2021, 10:45 PMraRaRa
09/08/2021, 6:51 AMlukeed
09/08/2021, 6:53 AMItsWendell
09/08/2021, 10:47 AMts
/**
* Colo interface from https://speed.cloudflare.com/locations
*/
export interface Colo {
iata: string;
lat?: number;
lon?: number;
cca2: string;
region?: string;
city: string;
}
/**
* Gets the current colo of the worker or durable object.
*/
export async function getColo(): Promise<Colo> {
// This endpoint returns an array with all of Cloudflare's network locations.
const coloUrl = "https://speed.cloudflare.com/locations";
const res = await fetch(coloUrl);
// Extract the colo which sent us the response. The colo is included in the CF-RAY response header.
// CF-RAY response header example: 1234567890-AMS
const parts = res.headers.get("CF-RAY").split("-");
const colo = parts[parts.length - 1];
const colos: Colo[] = await res.json();
return colos.find((x) => x.iata === colo);
}
ItsWendell
09/08/2021, 10:53 AMhannes
09/08/2021, 11:02 AMhannes
09/08/2021, 11:03 AMkristian
09/08/2021, 4:30 PMItsWendell
09/08/2021, 4:32 PM