Skip to content

Commit

Permalink
okay now working prod and dev
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Oct 18, 2023
1 parent c9cb035 commit dec1899
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
6 changes: 3 additions & 3 deletions src/routes/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }), {
Expand All @@ -31,15 +31,15 @@ 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

const response = await event.fetch(endpoints.prompt(), {
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')
Expand Down

0 comments on commit dec1899

Please sign in to comment.