diff --git a/app/components/plugin.module.scss b/app/components/plugin.module.scss
index 53c632468..a179e0a07 100644
--- a/app/components/plugin.module.scss
+++ b/app/components/plugin.module.scss
@@ -10,6 +10,7 @@
max-height: 240px;
overflow-y: auto;
white-space: pre-wrap;
+ min-width: 300px;
}
}
diff --git a/app/components/plugin.tsx b/app/components/plugin.tsx
index fcf671bff..35fb2abc6 100644
--- a/app/components/plugin.tsx
+++ b/app/components/plugin.tsx
@@ -249,6 +249,30 @@ export function PluginPage() {
+ {["bearer", "basic", "custom"].includes(
+ editingPlugin.authType as string,
+ ) && (
+
+
+
+ )}
{editingPlugin.authType == "custom" && (
`编辑插件 ${readonly ? "(只读)" : ""}`,
diff --git a/app/locales/en.ts b/app/locales/en.ts
index 80666f3b2..d2b27fdcd 100644
--- a/app/locales/en.ts
+++ b/app/locales/en.ts
@@ -559,10 +559,14 @@ const en: LocaleType = {
Basic: "Basic",
Bearer: "Bearer",
Custom: "Custom",
- CustomHeader: "Custom Header",
+ CustomHeader: "Parameter Name",
Token: "Token",
Proxy: "Using Proxy",
ProxyDescription: "Using proxies to solve CORS error",
+ Location: "Location",
+ LocationHeader: "Header",
+ LocationQuery: "Query",
+ LocationBody: "Body",
},
EditModal: {
Title: (readonly: boolean) =>
diff --git a/app/store/plugin.ts b/app/store/plugin.ts
index cad733a7e..260c33c32 100644
--- a/app/store/plugin.ts
+++ b/app/store/plugin.ts
@@ -13,6 +13,7 @@ export type Plugin = {
content: string;
builtin: boolean;
authType?: string;
+ authLocation?: string;
authHeader?: string;
authToken?: string;
usingProxy?: boolean;
@@ -50,16 +51,17 @@ export const FunctionToolService = {
const definition = yaml.load(plugin.content) as any;
const serverURL = definition?.servers?.[0]?.url;
const baseURL = !!plugin?.usingProxy ? "/api/proxy" : serverURL;
+ const headers: Record = {
+ "X-Base-URL": !!plugin?.usingProxy ? serverURL : undefined,
+ };
+ if (plugin?.authLocation == "header") {
+ headers[headerName] = tokenValue;
+ }
const api = new OpenAPIClientAxios({
definition: yaml.load(plugin.content) as any,
axiosConfigDefaults: {
baseURL,
- headers: {
- // 'Cache-Control': 'no-cache',
- // 'Content-Type': 'application/json', // TODO
- [headerName]: tokenValue,
- "X-Base-URL": !!plugin?.usingProxy ? serverURL : undefined,
- },
+ headers,
},
});
try {
@@ -111,20 +113,26 @@ export const FunctionToolService = {
funcs: operations.reduce((s, o) => {
// @ts-ignore
s[o.operationId] = function (args) {
- const argument = [];
+ const parameters: Record = {};
if (o.parameters instanceof Array) {
o.parameters.forEach((p) => {
// @ts-ignore
- argument.push(args[p?.name]);
+ parameters[p?.name] = args[p?.name];
// @ts-ignore
delete args[p?.name];
});
- } else {
- argument.push(null);
}
- argument.push(args);
+ if (plugin?.authLocation == "query") {
+ parameters[headerName] = tokenValue;
+ } else if (plugin?.authLocation == "body") {
+ args[headerName] = tokenValue;
+ }
// @ts-ignore
- return api.client[o.operationId].apply(null, argument);
+ return api.client[o.operationId](
+ parameters,
+ args,
+ api.axiosConfigDefaults,
+ );
};
return s;
}, {}),