Created
July 29, 2021 05:56
-
-
Save miguelmota/ecf4e58d97902d2cb09488d02ecd9aba to your computer and use it in GitHub Desktop.
JavaScript get IP address using Cloudflare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>IP</title> | |
</head> | |
<body> | |
<output id="output"></output> | |
<script> | |
const output = document.getElementById('output') | |
fetch('https://www.cloudflare.com/cdn-cgi/trace') | |
.then(res => res.text()) | |
.then(text => { | |
output.innerHTML += text.split('\n').join('<br>') | |
}) | |
.catch(err => { | |
output.innerHTML = err.message | |
}) | |
</script> | |
<body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment