Created
August 23, 2023 19:40
-
-
Save macbookandrew/211a3d4572847e80304b6d3895e9d8cf to your computer and use it in GitHub Desktop.
Cloudflare worker proxy for signed AWS S3 URLs
This file contains hidden or 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)) | |
}) | |
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