Skip to content

Instantly share code, notes, and snippets.

@macbookandrew
Created August 23, 2023 19:40
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 macbookandrew/211a3d4572847e80304b6d3895e9d8cf to your computer and use it in GitHub Desktop.
Save macbookandrew/211a3d4572847e80304b6d3895e9d8cf to your computer and use it in GitHub Desktop.
Cloudflare worker proxy for signed AWS S3 URLs
addEventListener('fetch', event => {
event.respondWith(handleRequest(event))
})
async function handleRequest(event) {
let url = new URL(event.request.url);
url.hostname = 'my-secure-bucket.s3-us-east-2.amazonaws.com';
let response = await fetch(url);
response = new Response(response.body, { ...response});
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment