mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
fix: fix /api/proxy-fetch transfer Authorization header
This commit is contained in:
@@ -38,7 +38,7 @@ const noCache = (ctx: any) => {
|
||||
}
|
||||
|
||||
const checkPermission = (ctx: any, next: any) => {
|
||||
const token = ctx.query._token || (ctx.headers['x-yn-authorization'] || ctx.headers.authorization || '').replace('Bearer ', '')
|
||||
const token = ctx.query._token || (ctx.headers['x-yn-authorization'] ?? (ctx.headers.authorization || '')).replace('Bearer', '').trim()
|
||||
|
||||
if (ctx.req._protocol || (!token && isLocalhost(ctx.request.ip))) {
|
||||
ctx.req.jwt = { role: 'admin' }
|
||||
|
||||
@@ -73,9 +73,7 @@ export async function proxyFetch (url: string, init?: Omit<RequestInit, 'body'>
|
||||
init.body = JSON.stringify(init.body)
|
||||
}
|
||||
|
||||
if (JWT_TOKEN) {
|
||||
init.headers = { ...init.headers, 'x-yn-authorization': 'Bearer ' + JWT_TOKEN }
|
||||
}
|
||||
init.headers = { ...init.headers, 'x-yn-authorization': 'Bearer ' + JWT_TOKEN }
|
||||
|
||||
const res: Response = await fetch(`/api/proxy-fetch/${url}`, init)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user