mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-06 10:57:40 +03:00
parent
247825bdd3
commit
b7cf3040ef
@ -6,6 +6,10 @@ from Cloudflare.
|
|||||||
|
|
||||||
On push to `main`, both of these (and the files they depend on) are uploaded to Cloudflare.
|
On push to `main`, both of these (and the files they depend on) are uploaded to Cloudflare.
|
||||||
|
|
||||||
|
### Deployment
|
||||||
|
|
||||||
|
These functions are deployed on push to main by the deploy_cloudflare.yml workflow. Worker Rules in Cloudflare intercept requests to zed.dev and proxy them to the appropriate workers.
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
|
|
||||||
You can use [wrangler](https://developers.cloudflare.com/workers/cli-wrangler/install-update) to test these workers locally, or to deploy custom versions.
|
You can use [wrangler](https://developers.cloudflare.com/workers/cli-wrangler/install-update) to test these workers locally, or to deploy custom versions.
|
||||||
|
@ -1,28 +1,19 @@
|
|||||||
/**
|
|
||||||
* 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 {
|
export default {
|
||||||
async fetch(request, env) {
|
async fetch(request, env) {
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
const key = url.pathname.slice(1).replace(/2$/, '');
|
const key = url.pathname.slice(1);
|
||||||
|
|
||||||
const object = await env.OPEN_SOURCE_WEBSITE_ASSETS_BUCKET.get(key);
|
const object = await env.OPEN_SOURCE_WEBSITE_ASSETS_BUCKET.get(key);
|
||||||
if (!object) {
|
if (!object) {
|
||||||
return await fetch('https://zed.dev/404');
|
return await fetch("https://zed.dev/404");
|
||||||
}
|
}
|
||||||
|
|
||||||
const headers = new Headers();
|
const headers = new Headers();
|
||||||
object.writeHttpMetadata(headers);
|
object.writeHttpMetadata(headers);
|
||||||
headers.set('etag', object.httpEtag);
|
headers.set("etag", object.httpEtag);
|
||||||
|
|
||||||
return new Response(object.body, {
|
return new Response(object.body, {
|
||||||
headers,
|
headers,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user