update cf context on id

This commit is contained in:
2025-12-18 00:20:20 -03:00
parent 8081e838a3
commit 11e8fa5a41
7 changed files with 35 additions and 21 deletions

View File

@@ -1,5 +1,7 @@
import type { Route } from './+types/upstream'
import { cloudflareContext } from '@repo/auth/context'
export const loader = proxy
export const action = proxy
@@ -9,8 +11,9 @@ async function proxy({
request,
context
}: Route.ActionArgs): Promise<Response> {
const cloudflare = context.get(cloudflareContext)
const { pathname, search } = new URL(request.url)
const url = new URL(pathname + search, context.cloudflare.env.ISSUER_URL)
const url = new URL(pathname + search, cloudflare.env.ISSUER_URL)
const headers = new Headers(request.headers)
const shouldCache =
@@ -44,7 +47,7 @@ async function proxy({
})
// Store asynchronously (dont block response)
context.cloudflare.ctx.waitUntil(cache.put(cacheKey, cacheResponse))
cloudflare.ctx.waitUntil(cache.put(cacheKey, cacheResponse))
}
const contentType = response.headers.get('content-type') || ''