From 6349ba077d74f6f2b5290990d05dcaf96a1c1659 Mon Sep 17 00:00:00 2001 From: ghdtjgus76 Date: Thu, 29 Aug 2024 22:57:30 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20api=20=ED=98=B8=EC=B6=9C=20=EC=97=90=EB=9F=AC=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/client/middleware.ts | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/apps/client/middleware.ts b/apps/client/middleware.ts index ef508930..d0f189d2 100644 --- a/apps/client/middleware.ts +++ b/apps/client/middleware.ts @@ -19,26 +19,20 @@ const middleware = async (req: NextRequest) => { } if (!cacheCookie) { - try { - const { memberRole } = await dashboardApi.getDashboardInfo(); + const { memberRole } = await dashboardApi.getDashboardInfo(); - if (memberRole !== "REGULAR") { - return NextResponse.redirect(new URL(routePath.auth, req.url)); - } - - const response = NextResponse.next(); - response.cookies.set(cookieKey["middleware-executed"], "true", { - httpOnly: true, - secure: true, - sameSite: "lax", - }); + if (memberRole !== "REGULAR") { + return NextResponse.redirect(new URL(routePath.auth, req.url)); + } - return response; - } catch (error) { - console.error("API 호출 오류:", error); + const response = NextResponse.next(); + response.cookies.set(cookieKey["middleware-executed"], "true", { + httpOnly: true, + secure: true, + sameSite: "lax", + }); - return NextResponse.next(); - } + return response; } return NextResponse.next();