fix upstream
This commit is contained in:
@@ -7,14 +7,24 @@ 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 response = await fetch(issuerUrl.toString(), {
|
||||
const pathname = new URL(request.url).pathname
|
||||
const url = new URL(pathname, context.cloudflare.env.ISSUER_URL)
|
||||
const headers = new Headers(request.headers)
|
||||
const response = await fetch(url.toString(), {
|
||||
method: request.method,
|
||||
headers: request.headers
|
||||
headers,
|
||||
...(['GET', 'HEAD'].includes(request.method)
|
||||
? {}
|
||||
: { body: await request.text() })
|
||||
})
|
||||
|
||||
return new Response(await response.text(), {
|
||||
const contentType = response.headers.get('content-type') || ''
|
||||
const body =
|
||||
contentType.includes('application/json') || contentType.startsWith('text/')
|
||||
? await response.text()
|
||||
: await response.arrayBuffer()
|
||||
|
||||
return new Response(body, {
|
||||
status: response.status,
|
||||
headers: response.headers
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user