Skip to content

Instantly share code, notes, and snippets.

@benwillkommen
Created September 9, 2020 19:11
Show Gist options
  • Save benwillkommen/498b3c9519ce33b3aeaa5e9002a13fb7 to your computer and use it in GitHub Desktop.
Save benwillkommen/498b3c9519ce33b3aeaa5e9002a13fb7 to your computer and use it in GitHub Desktop.
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
* Respond to the request
* @param {Request} request
*/
async function handleRequest(request) {
const originalResponse = await fetch('https://www.waterdatafortexas.org/reservoirs/recent-conditions.json', {
cf: {
cacheTtl: 3600,
cacheEverything: true
}
})
const response = new Response(originalResponse.body, originalResponse);
response.headers.set('Access-Control-Allow-Origin', '*');
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment