From c6dbd152d5a1f1b64a2bf4542ebe9f76da58ec0b Mon Sep 17 00:00:00 2001 From: bagasbanuna Date: Wed, 25 Feb 2026 15:34:22 +0800 Subject: [PATCH] Fix middleware ### NO Issue --- src/app_modules/waiting_room/view.tsx | 29 ++++++++++++++++++--------- src/middleware.tsx | 2 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/app_modules/waiting_room/view.tsx b/src/app_modules/waiting_room/view.tsx index 8a9057c5..3288598c 100644 --- a/src/app_modules/waiting_room/view.tsx +++ b/src/app_modules/waiting_room/view.tsx @@ -25,15 +25,21 @@ export default function WaitingRoom_View({ const [isLoadingHome, setIsLoadingHome] = useState(false); async function onClickLogout() { - setLoading(true); - const res = await fetch(`/api/auth/logout?id=${userLoginId}`, { - method: "GET", - }); + try { + setLoading(true); + const res = await fetch(`/api/auth/logout?id=${userLoginId}`, { + method: "GET", + }); - const result = await res.json(); - if (res.status === 200) { - ComponentGlobal_NotifikasiBerhasil(result.message); - router.push("/", { scroll: false }); + const result = await res.json(); + if (res.status === 200) { + ComponentGlobal_NotifikasiBerhasil(result.message); + router.push("/", { scroll: false }); + } + } catch (error) { + console.error("Error button to home", error); + } finally { + setLoading(false); } } @@ -83,7 +89,8 @@ export default function WaitingRoom_View({ Harap tunggu, Anda akan menerima pemberitahuan melalui - Whatsapp setelah disetujui. + Whatsapp setelah disetujui, untuk sementara anda bisa + menunggu pada halaman ini atau keluar. {isAccess && ( @@ -110,6 +117,10 @@ export default function WaitingRoom_View({ Home )} + + )} diff --git a/src/middleware.tsx b/src/middleware.tsx index 89f659f3..a96ef4cf 100644 --- a/src/middleware.tsx +++ b/src/middleware.tsx @@ -65,7 +65,7 @@ export const middleware = async (req: NextRequest) => { const { pathname } = req.nextUrl; - const apiBaseUrl = new URL(req.url).origin || process.env.NEXT_PUBLIC_API_URL; + const apiBaseUrl = process.env.NEXT_PUBLIC_API_URL || new URL(req.url).origin; // Removed excessive logging that was causing high CPU usage // const dbUrl = process.env.DATABASE_URL; // console.log("DATABASE_URL >>", dbUrl);