Skip to content

Commit

Permalink
Update main.js to fix the 401
Browse files Browse the repository at this point in the history
When the browser is accessed via http://user:[email protected], the bark worker returns status code 418, and it's unable to respond correctly to basic authentication, the status code should be 401.
  • Loading branch information
fuzzbuster authored Jan 2, 2025
1 parent 26bac99 commit 1288b4b
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 1288b4b

Please sign in to comment.