mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +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 () => {
|
||||
executeFunctionsMock.getCredentials.mockResolvedValue({
|
||||
url: 'https://custom-url.com',
|
||||
host: 'https://custom-url.com',
|
||||
});
|
||||
|
||||
await apiRequest.call(executeFunctionsMock, 'GET', '/v1beta/models', {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user