Deploy install.sh to cloudflare (#11866)

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-05-15 10:35:30 -06:00 committed by GitHub
parent f7c5d70740
commit 247825bdd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 126 additions and 35 deletions

View file

@ -0,0 +1,28 @@
/**
* Welcome to Cloudflare Workers! This is your first worker.
*
* - Run "npm run dev" in your terminal to start a development server
* - Open a browser tab at http://localhost:8787/ to see your worker in action
* - Run "npm run deploy" to publish your worker
*
* Learn more at https://developers.cloudflare.com/workers/
*/
export default {
async fetch(request, env) {
const url = new URL(request.url);
const key = url.pathname.slice(1).replace(/2$/, '');
const object = await env.OPEN_SOURCE_WEBSITE_ASSETS_BUCKET.get(key);
if (!object) {
return await fetch('https://zed.dev/404');
}
const headers = new Headers();
object.writeHttpMetadata(headers);
headers.set('etag', object.httpEtag);
return new Response(object.body, {
headers,
});
},
};