Skip to content

Commit

Permalink
test cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
birdpump committed Oct 13, 2023
1 parent 13eb50c commit 70cb3be
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions src/routes/admin/+page.server.js
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)
}

0 comments on commit 70cb3be

Please sign in to comment.