diff --git a/README.md b/README.md index 52ce62f..7268420 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ user1 = "passwd1" user2 = "passwd2" ``` -Now every access to PUT or POST request, and every access to the index page, requires an HTTP basic auth with the user-password pair listed above. For example: +Now every access to POST request, and every access to static pages, requires an HTTP basic auth with the user-password pair listed above. For example: ```shell $ curl example-pb.com diff --git a/src/index.js b/src/index.js index bd65312..7ef453c 100644 --- a/src/index.js +++ b/src/index.js @@ -61,9 +61,11 @@ async function handleNormalRequest(request, env, ctx) { } async function handlePostOrPut(request, env, ctx, isPut) { - const authResponse = verifyAuth(request, env) - if (authResponse !== null) { - return authResponse + if (!isPut) { // only POST requires auth, since PUT request already contains auth + const authResponse = verifyAuth(request, env) + if (authResponse !== null) { + return authResponse + } } const contentType = request.headers.get("content-type") || ""