There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix: enhancing the security of image proxy (#3176)
xiaodong zuo30dee1883534
diff --git a/.github/workflows/workers.yml b/.github/workflows/workers.ymlindex b0e5a79981..9637dd19dc 100644--- a/.github/workflows/workers.yml+++ b/.github/workflows/workers.yml@@ -18,4 +18,5 @@ jobs:uses: cloudflare/[email protected]with:apiToken: ${{ secrets.CF_API_TOKEN }}+ accountId: ${{ secrets.CF_ACCOUNT_ID }}workingDirectory: 'packages/workers'diff --git a/packages/workers/src/index.ts b/packages/workers/src/index.tsindex 7ec5596fb9..26da5810ef 100644--- a/packages/workers/src/index.ts+++ b/packages/workers/src/index.ts@@ -39,7 +39,12 @@ async function proxyImage(request: Request): Promise<Response> {const response = await fetch(imageRequest);const modifiedResponse = new Response(response.body);- modifiedResponse.headers.set('Access-Control-Allow-Origin', '*');++ modifiedResponse.headers.set(+ 'Access-Control-Allow-Origin',+ request.headers.get('Origin') ?? 'null'+ );+ modifiedResponse.headers.set('Vary', 'Origin');modifiedResponse.headers.set('Access-Control-Allow-Methods', 'GET');return modifiedResponse;@@ -47,7 +52,7 @@ async function proxyImage(request: Request): Promise<Response> {const handler = {async fetch(request: Request) {- if (!isOriginAllowed(request.headers.get('Origin') || '', ALLOW_ORIGIN)) {+ if (!isOriginAllowed(request.headers.get('Origin') ?? '', ALLOW_ORIGIN)) {return new Response('unauthorized', { status: 401 });}