quick fix worker auth

This commit is contained in:
polv committed 2026-03-22 00:53:11 +07:00
1 parent 904cdd0413
commit 4b6101b019
1 file changed
+4 -4
+4 -4
View File
@@ -13,16 +13,16 @@
export default {
async fetch(request, env) {
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 url = new URL(request.url);
// List files: GET /files
if (url.pathname === '/files') {
const list = await env.BUCKET.list();
const files = list.objects
.filter((o) => o.size)