mirror of
https://github.com/patarapolw/cjdic2.git
synced 2026-11-09 17:39:35 +00:00
quick fix worker auth
This commit is contained in:
1 parent
904cdd0413
commit
4b6101b019
1 file changed
+4
-4
@@ -13,16 +13,16 @@
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
async fetch(request, env) {
|
async fetch(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
|
||||||
|
// List files: GET /files
|
||||||
|
if (url.pathname === '/files') {
|
||||||
// Auth check first
|
// Auth check first
|
||||||
const auth = request.headers.get("Authorization");
|
const auth = request.headers.get("Authorization");
|
||||||
if (auth !== `Bearer ${env.YOMITAN_STORAGE_API_TOKEN}`) {
|
if (auth !== `Bearer ${env.YOMITAN_STORAGE_API_TOKEN}`) {
|
||||||
return new Response("Unauthorized", { status: 401 });
|
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 list = await env.BUCKET.list();
|
||||||
const files = list.objects
|
const files = list.objects
|
||||||
.filter((o) => o.size)
|
.filter((o) => o.size)
|
||||||
|
|||||||
Reference in new issue
Block a user