Last active
April 14, 2021 19:40
-
-
Save Zertz/c079d283e3053acd876d810ecb36868e to your computer and use it in GitHub Desktop.
Geolocation with Cloudflare Workers
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
addEventListener("fetch", event => { | |
const response = new Response(`{"country":"${event.request.headers.get("cf-ipcountry")}"}`, { | |
headers: { | |
"Access-Control-Allow-Origin": "*", | |
"Content-Type": "application/json" | |
} | |
}) | |
event.respondWith(response) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment