24 lines
529 B
TypeScript
24 lines
529 B
TypeScript
import type { Route } from './+types'
|
|
|
|
export const loader = proxy
|
|
export const action = proxy
|
|
|
|
async function proxy({
|
|
request,
|
|
context
|
|
}: Route.ActionArgs): Promise<Response> {
|
|
const url = new URL(request.url)
|
|
const issuerUrl = new URL(url.pathname, context.cloudflare.env.ISSUER_URL)
|
|
const r = await fetch(issuerUrl.toString(), {
|
|
method: request.method,
|
|
headers: request.headers
|
|
})
|
|
|
|
console.log('[response]', r)
|
|
|
|
return new Response(await r.text(), {
|
|
status: r.status,
|
|
headers: r.headers
|
|
})
|
|
}
|