From ca482e8956b230f282aa39c8b1abb51466c33616 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Thu, 13 Jun 2024 18:40:49 +0200 Subject: [PATCH] refactor: :recycle: remove code duplication --- routes/_middleware.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/routes/_middleware.ts b/routes/_middleware.ts index 9a8d798..1e31fcf 100644 --- a/routes/_middleware.ts +++ b/routes/_middleware.ts @@ -10,12 +10,10 @@ export async function handler(request: Request, ctx: FreshContext) { response.headers.set('Service-Worker-Allowed', '/') } - const cookies = getCookies(request.headers) - // Start session - if (SessionStore.getSession(cookies['_SESSION'] ?? '') === undefined) { + if (SessionStore.getFromRequest(request) === undefined) { // Clear outdated cookies - for (const cookie in cookies) { + for (const cookie in getCookies(request.headers)) { setCookie(response.headers, { name: cookie, value: '',