Skip to content

Commit cd9ddba

Browse files
committed
Update hooks logs to improve traceability experience
1 parent b66d7d3 commit cd9ddba

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/hooks.server.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import { FRACTAL_SERVER_HOST } from '$env/static/private'
22

33
export async function handle({ event, resolve }) {
4+
console.log(`[${event.request.method}] - ${event.url.pathname}`)
45

56
if (event.url.pathname == '/' || event.url.pathname.startsWith('/auth')) {
7+
console.log('Public page - No auth required')
68
return await resolve(event)
79
}
810

911
// Authentication guard
1012
const fastApiUsersAuth = event.cookies.get('fastapiusersauth')
1113
if (!fastApiUsersAuth) {
14+
console.log('Authentication required - No auth cookie found - Redirecting to login')
1215
return new Response(null, { status: 302, headers: { location: '/auth/login' } })
1316
}
17+
1418
const whoami = await event.fetch(`${FRACTAL_SERVER_HOST}/auth/whoami`)
1519
if (whoami.ok) {
1620
return await resolve(event)
1721
} else {
22+
console.log('Validation of authentication - Error loading user info')
1823
return new Response(null, { status: 302, headers: { location: '/auth/login' } })
1924
}
2025
}

0 commit comments

Comments
 (0)