From f714ef3fa625fe87d2501366fec5f6a76ff9d7be Mon Sep 17 00:00:00 2001 From: AlexBocken Date: Tue, 18 Jul 2023 14:20:50 +0200 Subject: [PATCH] cookie util --- src/utils/cookie.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/utils/cookie.js diff --git a/src/utils/cookie.js b/src/utils/cookie.js new file mode 100644 index 0000000..d628ac8 --- /dev/null +++ b/src/utils/cookie.js @@ -0,0 +1,11 @@ +// utils/cookie.js +export function getJWTFromRequest(request) { + const cookies = request.headers.get("cookie") || ''; + const jwtCookie = cookies.split(';').find(cookie => cookie.trim().startsWith('UserSession=')); + + if (jwtCookie) { + return jwtCookie.split('=')[1] || ''; + } + + return ''; +}