Skip to content

Instantly share code, notes, and snippets.

Last active April 4, 2023 21:22
What would you like to do?
Trace current user's location via javascript with CloudFlare provided the /cdn-cgi/trace is enabled.
contentType: 'application/text; charset=utf-8',
crossBrowser: true,
type: 'GET',
url: '/cdn-cgi/trace',
var data = d.replace(/[\r\n]+/g, '","').replace(/\=+/g, '":"');
data = '{"' + data.slice(0, data.lastIndexOf('","')) + '"}';
var jsondata = $.parseJSON(data);
Copy link

Copy link

thedtvn commented Jan 15, 2023

.then(res => res.text() ).then(t => {
    var data = t.replace(/[\r\n]+/g, '","').replace(/\=+/g, '":"');
        data = '{"' + data.slice(0, data.lastIndexOf('","')) + '"}';
    var jsondata = JSON.parse(data);

code if page is add to cloudflare

  • /cdn-cgi/trace is work on every domain on cloudflare DNS or network

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment