Created
September 9, 2020 19:11
-
-
Save benwillkommen/498b3c9519ce33b3aeaa5e9002a13fb7 to your computer and use it in GitHub Desktop.
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 => { | |
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