update cf on insights

This commit is contained in:
2025-12-18 00:20:02 -03:00
parent 3857620f89
commit 8081e838a3
10 changed files with 51 additions and 45 deletions

View File

@@ -1,7 +1,7 @@
import type { Route } from './+types/route'
import type { User } from '@repo/auth/auth'
import { userContext } from '@repo/auth/context'
import { userContext, cloudflareContext } from '@repo/auth/context'
import { authMiddleware } from '@repo/auth/middleware/auth'
export const middleware: Route.MiddlewareFunction[] = [authMiddleware]
@@ -13,8 +13,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}`)