fix: add preferred team middleware

This commit is contained in:
David Nguyen
2025-02-26 19:42:42 +11:00
parent 5b4db51051
commit 6474b4a524
11 changed files with 173 additions and 54 deletions

View File

@ -0,0 +1,14 @@
/**
* Todo: Use library for cookies instead.
*/
export const extractCookieFromHeaders = (cookieName: string, headers: Headers): string | null => {
const cookieHeader = headers.get('cookie') || '';
const cookiePairs = cookieHeader.split(';');
const cookie = cookiePairs.find((pair) => pair.trim().startsWith(cookieName));
if (!cookie) {
return null;
}
return cookie.split('=')[1].trim();
};