mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(Google Gemini Node): Use custom host from credential (#18405)
This commit is contained in:
@@ -11,7 +11,7 @@ describe('GoogleGemini transport', () => {
|
|||||||
|
|
||||||
it('should call httpRequestWithAuthentication with correct parameters', async () => {
|
it('should call httpRequestWithAuthentication with correct parameters', async () => {
|
||||||
executeFunctionsMock.getCredentials.mockResolvedValue({
|
executeFunctionsMock.getCredentials.mockResolvedValue({
|
||||||
url: 'https://custom-url.com',
|
host: 'https://custom-url.com',
|
||||||
});
|
});
|
||||||
|
|
||||||
await apiRequest.call(executeFunctionsMock, 'GET', '/v1beta/models', {
|
await apiRequest.call(executeFunctionsMock, 'GET', '/v1beta/models', {
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ type RequestParameters = {
|
|||||||
option?: IDataObject;
|
option?: IDataObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type GooglePalmApiCredentials = {
|
||||||
|
host: string;
|
||||||
|
apiKey: string;
|
||||||
|
};
|
||||||
|
|
||||||
export async function apiRequest(
|
export async function apiRequest(
|
||||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||||
method: IHttpRequestMethods,
|
method: IHttpRequestMethods,
|
||||||
@@ -20,12 +25,12 @@ export async function apiRequest(
|
|||||||
) {
|
) {
|
||||||
const { body, qs, option, headers } = parameters ?? {};
|
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}`;
|
let url = `https://generativelanguage.googleapis.com${endpoint}`;
|
||||||
|
|
||||||
if (credentials.url) {
|
if (credentials.host) {
|
||||||
url = `${credentials?.url as string}${endpoint}`;
|
url = `${credentials.host}${endpoint}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
|
|||||||
Reference in New Issue
Block a user