update cf context to studio

This commit is contained in:
2025-12-18 00:15:18 -03:00
parent 8c7c3034d4
commit 3857620f89
7 changed files with 52 additions and 40 deletions

View File

@@ -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}`)