This simplifies upgrading an HTTP request to a websocket, I believe, and fixes sending refresh auth tokens.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4791 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2024-01-25 18:00:23 +00:00
parent 44b5ba1a9a
commit 00ba74a6c4
3 changed files with 78 additions and 73 deletions

View File

@ -202,11 +202,9 @@ function socket(request, response, client) {
}
}
if (refresh) {
return {
'Set-Cookie': `session=${refresh.token}; path=/; Max-Age=${refresh.interval}; Secure; SameSite=Strict`,
};
}
response.upgrade(100, refresh ? {
'Set-Cookie': `session=${refresh.token}; path=/; Max-Age=${refresh.interval}; Secure; SameSite=Strict`,
} : {});
}
export { socket, App };

View File

@ -982,7 +982,7 @@ loadSettings().then(function() {
httpd.set_http_redirect(gGlobalSettings.http_redirect);
}
httpd.all("/login", auth.handler);
httpd.registerSocketHandler("/app/socket", app.socket);
httpd.all("/app/socket", app.socket);
httpd.all("", function(request, response) {
let match;
if (request.uri === "/" || request.uri === "") {