File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change 11import { FRACTAL_SERVER_HOST } from '$env/static/private'
22
33export 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}
You can’t perform that action at this time.
0 commit comments