chore: update auth value logic (#3630)
This commit is contained in:
parent
4ea2b66e1a
commit
9bfd979b08
|
@ -9,7 +9,8 @@ const serverConfig = getServerSideConfig();
|
||||||
export async function requestOpenai(req: NextRequest) {
|
export async function requestOpenai(req: NextRequest) {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
|
|
||||||
let authValue = req.headers.get("Authorization") ?? "";
|
var authValue,
|
||||||
|
authHeaderName = "";
|
||||||
if (serverConfig.isAzure) {
|
if (serverConfig.isAzure) {
|
||||||
authValue =
|
authValue =
|
||||||
req.headers
|
req.headers
|
||||||
|
@ -17,8 +18,12 @@ export async function requestOpenai(req: NextRequest) {
|
||||||
?.trim()
|
?.trim()
|
||||||
.replaceAll("Bearer ", "")
|
.replaceAll("Bearer ", "")
|
||||||
.trim() ?? "";
|
.trim() ?? "";
|
||||||
|
|
||||||
|
authHeaderName = "api-key";
|
||||||
|
} else {
|
||||||
|
authValue = req.headers.get("Authorization") ?? "";
|
||||||
|
authHeaderName = "Authorization";
|
||||||
}
|
}
|
||||||
const authHeaderName = serverConfig.isAzure ? "api-key" : "Authorization";
|
|
||||||
|
|
||||||
let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll(
|
let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll(
|
||||||
"/api/openai/",
|
"/api/openai/",
|
||||||
|
|
Loading…
Reference in New Issue