fix(api): modify session endpoint to check for a cookie as well as an authorization header

This commit is contained in:
parent 5a5719dc52
commit d8ae07baa3
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -1,7 +1,14 @@
import jwt from "jsonwebtoken";
import { log } from "~/lib/server/logger";
export default eventHandler((event) => { export default eventHandler((event) => {
let ahead = (
getHeaders(event).authorization ||
getCookie(event, "auth:token") ||
""
)?.replace("Bearer ", "");
if (event.context.currentUser) { if (event.context.currentUser) {
return { return {
token: getHeader(event, "Authorization"), token: ahead,
user: event.context.currentUser, user: event.context.currentUser,
}; };
} else { } else {