Skip to content

Instantly share code, notes, and snippets.

View jimbojsb's full-sized avatar

Josh Butts jimbojsb

View GitHub Profile
@jimbojsb
jimbojsb / gist:41f8331a0469db4b5ea6f7d690b674c3
Created July 24, 2018 04:51
Cloudflare Github Validation
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const ip = request.headers.get('cf-connecting-ip');
const ghHeaders = new Headers();
ghHeaders.append("User-agent", "Cloudflare")
response = await fetch('https://api.github.com/meta', {headers: ghHeaders}).then(function(response) {