From f9fbeebe7523b82fdbfa4577c3e9a0f53e63b70e Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 24 Oct 2023 09:51:49 +0100 Subject: [PATCH] fix playerId cookie --- src/middleware.ts | 2 +- src/store/settingsStore.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/middleware.ts b/src/middleware.ts index 5e878a6..4d6e841 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -9,7 +9,7 @@ export function middleware(request: NextRequest) { if (pathname == "/") { if (playerIdCookie) { return NextResponse.redirect( - new URL(`/player/${playerIdCookie}`, request.url), + new URL(`/player/${playerIdCookie.value}`, request.url), ); } else { return NextResponse.redirect(new URL("/search", request.url)); diff --git a/src/store/settingsStore.ts b/src/store/settingsStore.ts index f11250e..b78f2d9 100644 --- a/src/store/settingsStore.ts +++ b/src/store/settingsStore.ts @@ -44,7 +44,9 @@ export const useSettingsStore = create()( player: playerData, }); - cookieCutter.set("playerId", playerData.id); + cookieCutter.set("playerId", playerData.id, { + path: "/", + }); }, async addFriend(friendId: string) {