Skip to content

Commit

Permalink
try to only set the www-authenticate header on non-interactive sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
sdumetz committed Sep 21, 2023
1 parent 166b157 commit 1ce7c80
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion source/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ export default async function createServer(config = defaultConfig) :Promise<expr
}
let code = (error instanceof HTTPError )? error.code : 500;

if(code === 401){
if(code === 401 && !(req.get("Accept")?.startsWith("text/html") && req.get("User-Agent")?.startsWith("Mozilla"))){
//We try to NOT send the header for browser requests because we prefer the HTML login to the browser's popup
//Browser tends to prefer text/html and always send Mozilla/5.0 at the beginning of their user-agent
//If someone has customized their headers, they'll get the ugly popup and live with it.
res.set("WWW-Authenticate", "Basic realm=\"authenticated access\"");
}

Expand Down

0 comments on commit 1ce7c80

Please sign in to comment.