update cf context to studio
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { Route } from './+types'
|
||||
|
||||
import type { User } from '@repo/auth/auth'
|
||||
import { userContext } from '@repo/auth/context'
|
||||
import { userContext, cloudflareContext } from '@repo/auth/context'
|
||||
|
||||
export const loader = proxy
|
||||
export const action = proxy
|
||||
@@ -11,8 +11,9 @@ async function proxy({
|
||||
context
|
||||
}: Route.ActionArgs): Promise<Response> {
|
||||
const pathname = new URL(request.url).pathname.replace(/^\/api\//, '')
|
||||
const user = context.get(userContext) as User
|
||||
const url = new URL(pathname, context.cloudflare.env.API_URL)
|
||||
const cloudflare = context.get(cloudflareContext)
|
||||
const user = context.get(userContext)!
|
||||
const url = new URL(pathname, cloudflare.env.API_URL)
|
||||
const headers = new Headers(request.headers)
|
||||
|
||||
headers.set('Authorization', `Bearer ${user.accessToken}`)
|
||||
|
||||
Reference in New Issue
Block a user