Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save owenconti/fc8483a11f32127ac33d78dda84f9d5f to your computer and use it in GitHub Desktop.
Save owenconti/fc8483a11f32127ac33d78dda84f9d5f to your computer and use it in GitHub Desktop.
Create a reverse proxy with Cloudflare Workers
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