Skip to content

Instantly share code, notes, and snippets.

View Klumper's full-sized avatar

Niels Klumper Klumper

  • Almelo, The Netherlands
View GitHub Profile
@Klumper
Klumper / cloudflareTrace.js
Created January 13, 2021 09:11
Trace current user's location with javascript fetch, using cloudflare.com/cdn-cgi/trace.
const cloudflareTrace = async () => {
try {
const response = await fetch('https://www.cloudflare.com/cdn-cgi/trace')
const rawData = await response.text();
const jsonData = Object.fromEntries(
rawData.trim()
.split('\n')
.map(line => line.split('='))
);
return jsonData;