Fix null checks for user and CIO cookie in event handling

- Updated the condition to safely check for the presence of user data in event.locals, preventing potential runtime errors when accessing nested properties.
This commit is contained in:
Rotimi Best
2026-03-28 11:50:53 +01:00
parent b1d138ce60
commit 0072746c67
+1 -1
View File
@@ -32,7 +32,7 @@ const handlePagesRoutes: Handle = async ({ event, resolve }) => {
return resolve(event);
}
if (!event.locals.user && !hasCioCookie) {
if (!event?.locals?.user && !hasCioCookie) {
console.log('no user and no cio cookie, redirecting to login');
const shouldAddRedirectParam = !pathname.includes(ROUTE.LOGOUT);
const fullPath = pathname + event.url.search;