Everlasting Summer Posted February 13 Share Posted February 13 (edited) Here is a super simple JavaScript code you could use on all websites which are using Cloudflare CDN. It allows you to quickly retrieve some connection data, such as IP, location, CF server, whether or not the user uses WARP VPN, etc. async function getCloudflareTraceJSON() { try { const response = await fetch(`https://${location.hostname}/cdn-cgi/trace`); const traceData = await response.text(); const traceEntries = traceData.trim().split('\n').map(e => e.split('=')); return Object.fromEntries(traceEntries); } catch (error) { console.error(error); return null; } } getCloudflareTraceJSON().then(console.log); Usage example: getCloudflareTraceJSON().then( traceData => { if (traceData.loc === 'US') { console.log('Location: USA'); } else { console.log('Location: Not USA'); } } ); Edited February 13 by Everlasting Summer Link to comment Share on other sites More sharing options...
Recommended Posts