mirror of
https://github.com/patarapolw/cjdic2.git
synced 2026-11-08 17:35:18 +00:00
quick fix worker auth
This commit is contained in:
1 parent
904cdd0413
commit
4b6101b019
1 file changed
+6
-6
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user