diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts index 59ce005..640f220 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -2,16 +2,12 @@ import { users, Client } from '@kittycad/lib' /** @type {import('./$types').LayoutData} */ export const load = async ({ cookies }) => { - let token = cookies.get('__Secure-next-auth.session-token') - console.log('token', token) + const token = cookies.get('__Secure-next-auth.session-token') const client = new Client(token) - console.log('client', client) const response = await users.get_user_self({ client }) - console.log('response', response) - return { - user: 'error_code' in response ? { user: undefined } : response + user: 'error_code' in response ? { user: undefined } : { user: response } } } diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index ba3f4f1..b9f7a58 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -12,7 +12,7 @@ type SubmissionResponse = { } export const load = async ({ cookies }) => { - let token = cookies.get('__Secure-next-auth.session-token') + const token = cookies.get('__Secure-next-auth.session-token') console.log('token', token) const response = await fetch(endpoints.list({ limit: 10 }), { @@ -31,7 +31,7 @@ export const load = async ({ cookies }) => { export const actions = { default: async (event) => { - console.log('event', event) + const token = event.cookies.get('__Secure-next-auth.session-token') const formData = await event.request.formData() // TODO make a call to the prompt API @@ -39,7 +39,7 @@ export const actions = { method: 'POST', headers: { 'Content-Type': 'application/json', - Authorization: `Bearer ${import.meta.env.VITE_AUTH_TOKEN}` + Authorization: `Bearer ${token}` }, body: JSON.stringify({ prompt: formData.get('prompt')