This commit is contained in:
lloydzhou 2024-09-03 16:23:54 +08:00
parent 236736deea
commit 4fdd997108
1 changed files with 4 additions and 3 deletions

View File

@ -48,13 +48,14 @@ export const FunctionToolService = {
: plugin?.authType == "bearer"
? ` Bearer ${plugin?.authToken}`
: plugin?.authToken;
const authLocation = plugin?.authLocation || "header";
const definition = yaml.load(plugin.content) as any;
const serverURL = definition?.servers?.[0]?.url;
const baseURL = !!plugin?.usingProxy ? "/api/proxy" : serverURL;
const headers: Record<string, string | undefined> = {
"X-Base-URL": !!plugin?.usingProxy ? serverURL : undefined,
};
if (plugin?.authLocation == "header") {
if (authLocation == "header") {
headers[headerName] = tokenValue;
}
const api = new OpenAPIClientAxios({
@ -122,9 +123,9 @@ export const FunctionToolService = {
delete args[p?.name];
});
}
if (plugin?.authLocation == "query") {
if (authLocation == "query") {
parameters[headerName] = tokenValue;
} else if (plugin?.authLocation == "body") {
} else if (authLocation == "body") {
args[headerName] = tokenValue;
}
// @ts-ignore