From 1cb1da8097716eb81bbc6ae3118e932963316cd1 Mon Sep 17 00:00:00 2001 From: djknaeckebrot Date: Tue, 10 Dec 2024 09:19:01 +0100 Subject: [PATCH] fix: replace hardcoded gitlab.com with dynamic urls --- packages/server/src/utils/providers/gitlab.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/server/src/utils/providers/gitlab.ts b/packages/server/src/utils/providers/gitlab.ts index 504ff841..096f9e28 100644 --- a/packages/server/src/utils/providers/gitlab.ts +++ b/packages/server/src/utils/providers/gitlab.ts @@ -26,7 +26,7 @@ export const refreshGitlabToken = async (gitlabProviderId: string) => { return; } - const response = await fetch("https://gitlab.com/oauth/token", { + const response = await fetch(`${gitlabProvider.gitlabUrl}/oauth/token`, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded", @@ -122,7 +122,7 @@ export const cloneGitlabRepository = async ( const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH; const outputPath = join(basePath, appName, "code"); await recreateDirectory(outputPath); - const repoclone = `gitlab.com/${gitlabPathNamespace}.git`; + const repoclone = `${gitlab?.gitlabUrl.replace(/^https?:\/\//, "")}/${gitlabPathNamespace}.git`; const cloneUrl = `https://oauth2:${gitlab?.accessToken}@${repoclone}`; try { @@ -218,7 +218,7 @@ export const getGitlabCloneCommand = async ( const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH; const outputPath = join(basePath, appName, "code"); await recreateDirectory(outputPath); - const repoclone = `gitlab.com/${gitlabPathNamespace}.git`; + const repoclone = `${gitlab?.gitlabUrl.replace(/^https?:\/\//, "")}/${gitlabPathNamespace}.git`; const cloneUrl = `https://oauth2:${gitlab?.accessToken}@${repoclone}`; const cloneCommand = ` @@ -352,7 +352,7 @@ export const cloneRawGitlabRepository = async (entity: Compose) => { await recreateDirectory(outputPath); const gitlabUrl = gitlabProvider.gitlabUrl; // What happen with oauth in self hosted instances? - const repoclone = `${gitlabProvider.gitlabUrl}/${gitlabPathNamespace}.git`; + const repoclone = `${gitlabUrl.replace(/^https?:\/\//, "")}/${gitlabPathNamespace}.git`; const cloneUrl = `https://oauth2:${gitlabProvider?.accessToken}@${repoclone}`; try { @@ -392,7 +392,7 @@ export const cloneRawGitlabRepositoryRemote = async (compose: Compose) => { await refreshGitlabToken(gitlabId); const basePath = COMPOSE_PATH; const outputPath = join(basePath, appName, "code"); - const repoclone = `${gitlabProvider.gitlabUrl}/${gitlabPathNamespace}.git`; + const repoclone = `${gitlabProvider.gitlabUrl.replace(/^https?:\/\//, "")}/${gitlabPathNamespace}.git`; const cloneUrl = `https://oauth2:${gitlabProvider?.accessToken}@${repoclone}`; try { const command = `