From 4b6101b0194800ef9b70b9946d86b58e4bcf6ef4 Mon Sep 17 00:00:00 2001 From: polv Date: Sun, 22 Mar 2026 00:53:11 +0700 Subject: [PATCH] quick fix worker auth --- storage-worker/src/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/storage-worker/src/index.ts b/storage-worker/src/index.ts index 331b165..6ca5a68 100644 --- a/storage-worker/src/index.ts +++ b/storage-worker/src/index.ts @@ -13,16 +13,16 @@ export default { async fetch(request, env) { - // Auth check first - const auth = request.headers.get("Authorization"); - if (auth !== `Bearer ${env.YOMITAN_STORAGE_API_TOKEN}`) { - return new Response("Unauthorized", { status: 401 }); - } - const url = new URL(request.url); // List files: GET /files if (url.pathname === '/files') { + // Auth check first + const auth = request.headers.get("Authorization"); + if (auth !== `Bearer ${env.YOMITAN_STORAGE_API_TOKEN}`) { + return new Response("Unauthorized", { status: 401 }); + } + const list = await env.BUCKET.list(); const files = list.objects .filter((o) => o.size)