add cloudflare context to admin
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
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 +12,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