fix(Google Gemini Node): Use custom host from credential (#18405)

This commit is contained in:
Elias Meire
2025-08-15 15:19:28 +02:00
committed by GitHub
parent 2203d1e77f
commit 041672eb6c
2 changed files with 9 additions and 4 deletions

View File

@@ -11,7 +11,7 @@ describe('GoogleGemini transport', () => {
it('should call httpRequestWithAuthentication with correct parameters', async () => {
executeFunctionsMock.getCredentials.mockResolvedValue({
url: 'https://custom-url.com',
host: 'https://custom-url.com',
});
await apiRequest.call(executeFunctionsMock, 'GET', '/v1beta/models', {

View File

@@ -12,6 +12,11 @@ type RequestParameters = {
option?: IDataObject;
};
type GooglePalmApiCredentials = {
host: string;
apiKey: string;
};
export async function apiRequest(
this: IExecuteFunctions | ILoadOptionsFunctions,
method: IHttpRequestMethods,
@@ -20,12 +25,12 @@ export async function apiRequest(
) {
const { body, qs, option, headers } = parameters ?? {};
const credentials = await this.getCredentials('googlePalmApi');
const credentials = await this.getCredentials<GooglePalmApiCredentials>('googlePalmApi');
let url = `https://generativelanguage.googleapis.com${endpoint}`;
if (credentials.url) {
url = `${credentials?.url as string}${endpoint}`;
if (credentials.host) {
url = `${credentials.host}${endpoint}`;
}
const options = {