Created
July 11, 2021 04:19
-
-
Save owenconti/2b463fa07cafabe33a9171b8cd245637 to your computer and use it in GitHub Desktop.
Create a reverse proxy 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) => { | |
event.respondWith( | |
handleRequest(event.request).catch( | |
(err) => new Response(err.stack, { status: 500 }) | |
) | |
); | |
}); | |
async function handleRequest(request) { | |
const { search } = new URL(request.url); | |
const params = new URLSearchParams(search); | |
params.set('token', OHSEESNAPS_TOKEN); | |
return fetch(`https://ohseesnaps.com/api/snap?${params.toString()}`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment