-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
import { redirect } from '@sveltejs/kit'; | ||
|
||
export async function load({ request }) { | ||
const authToken = request.headers.get('Authorization'); | ||
// export async function load({ request }) { | ||
// const authToken = request.headers.get('Authorization'); | ||
|
||
console.log(request) | ||
try { | ||
console.log("hello") | ||
const response = await fetch('http://mysql-container/auth/checkAuth', { | ||
headers: { | ||
'Authorization': authToken | ||
} | ||
}); | ||
console.log(response.ok) | ||
if (!response.ok) { | ||
throw redirect(302, '/login'); | ||
} | ||
// console.log(request) | ||
// try { | ||
// console.log("hello") | ||
// const response = await fetch('http://locker-backend:3000/auth/checkAuth', { | ||
// headers: { | ||
// 'Authorization': authToken | ||
// } | ||
// }); | ||
// console.log(response.ok) | ||
// if (!response.ok) { | ||
// throw redirect(302, '/login'); | ||
// } | ||
|
||
// Continue loading the route as usual | ||
return { props: {} }; | ||
// // Continue loading the route as usual | ||
// return { props: {} }; | ||
|
||
} catch (error) { | ||
console.error("Error checking authentication:", error); | ||
throw redirect(302, '/login'); | ||
} | ||
// } catch (error) { | ||
// console.error("Error checking authentication:", error); | ||
// throw redirect(302, '/login'); | ||
// } | ||
// } | ||
|
||
export function load({ cookies }) { | ||
const visited = cookies.get('connect.sid'); | ||
|
||
// cookies.set('visited', 'true', { path: '/' }); | ||
|
||
console.log(visited) | ||
} |