Skip to content

Instantly share code, notes, and snippets.

@luandevpro
Created August 18, 2019 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luandevpro/ed50a7ac78e429ffd0966bb6e941e046 to your computer and use it in GitHub Desktop.
Save luandevpro/ed50a7ac78e429ffd0966bb6e941e046 to your computer and use it in GitHub Desktop.
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
async function fetchAndApply(request) {
if (request.headers.get('cf-connecting-ip') !== '225.0.0.1') {
return new Response('Sorry, this page is not available.',
{ status: 403, statusText: 'Forbidden' })
}
return fetch(request)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment