Skip to content

Commit

Permalink
feat: Add session cookie to API requests in profile page server load
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmorley15 committed Feb 16, 2025
1 parent 00f0fc9 commit af33ace
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions frontend/src/routes/profile/[uuid]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,24 @@ export const load: PageServerLoad = async (event: RequestEvent) => {
// let sessionId = event.cookies.get('sessionid');
let stats = null;

let res = await event.fetch(`${endpoint}/api/stats/counts/${username}`, {});
let res = await event.fetch(`${endpoint}/api/stats/counts/${username}`, {
headers: {
'Content-Type': 'application/json',
Cookie: `sessionid=${event.cookies.get('sessionid')}`
}
});
if (!res.ok) {
console.error('Failed to fetch user stats');
} else {
stats = await res.json();
}

let userData = await event.fetch(`${endpoint}/auth/user/${username}/`);
let userData = await event.fetch(`${endpoint}/auth/user/${username}/`, {
headers: {
'Content-Type': 'application/json',
Cookie: `sessionid=${event.cookies.get('sessionid')}`
}
});
if (!userData.ok) {
return error(404, 'Not found');
}
Expand Down

0 comments on commit af33ace

Please sign in to comment.