Skip to content

Commit

Permalink
Merge pull request #11 from fuzzbuster/patch-1
Browse files Browse the repository at this point in the history
Update main.js to fix the 401
  • Loading branch information
cwxiaos authored Jan 2, 2025
2 parents 26bac99 + 1288b4b commit 552d242
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ async function handleRequest(request, env, ctx) {
}
case "/info": {
if (!util.validateBasicAuth(request)) {
return new Response('I\'m a teapot', {
status: 418,
headers: {
'content-type': 'text/plain',
}
})
return new Response('Unauthorized', {
status: 401,
headers: {
'content-type': 'text/plain',
'WWW-Authenticate': 'Basic',
}
})
}

return handler.info(searchParams)
Expand All @@ -45,10 +46,11 @@ async function handleRequest(request, env, ctx) {

if (pathParts[1]) {
if (!util.validateBasicAuth(request)) {
return new Response('I\'m a teapot', {
status: 418,
return new Response('Unauthorized', {
status: 401,
headers: {
'content-type': 'text/plain',
'WWW-Authenticate': 'Basic',
}
})
}
Expand Down Expand Up @@ -564,4 +566,4 @@ class Util {
}
}

const util = new Util()
const util = new Util()

0 comments on commit 552d242

Please sign in to comment.