From e423b56f4251c03533ab26a5c9095f6304cbf9a4 Mon Sep 17 00:00:00 2001 From: Gabriel Dugny Date: Wed, 11 Jun 2025 18:33:53 +0200 Subject: [PATCH] fix(gitlab): Properly handle auth for Gitlab project avatars (#345) --- packages/backend/src/repoCompileUtils.ts | 7 +++++-- packages/web/src/lib/utils.ts | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/repoCompileUtils.ts b/packages/backend/src/repoCompileUtils.ts index 71dc89a7..8722b928 100644 --- a/packages/backend/src/repoCompileUtils.ts +++ b/packages/backend/src/repoCompileUtils.ts @@ -121,7 +121,10 @@ export const compileGitlabConfig = async ( const isFork = project.forked_from_project !== undefined; const repoDisplayName = project.path_with_namespace; const repoName = path.join(repoNameRoot, repoDisplayName); - + // project.avatar_url is not directly accessible with tokens; use the avatar API endpoint if available + const avatarUrl = project.avatar_url + ? new URL(`/api/v4/projects/${project.id}/avatar`, hostUrl).toString() + : null; logger.debug(`Found gitlab repo ${repoDisplayName} with webUrl: ${projectUrl}`); const record: RepoData = { @@ -132,7 +135,7 @@ export const compileGitlabConfig = async ( webUrl: projectUrl, name: repoName, displayName: repoDisplayName, - imageUrl: project.avatar_url, + imageUrl: avatarUrl, isFork: isFork, isArchived: !!project.archived, org: { diff --git a/packages/web/src/lib/utils.ts b/packages/web/src/lib/utils.ts index 6d3913ef..8660fe98 100644 --- a/packages/web/src/lib/utils.ts +++ b/packages/web/src/lib/utils.ts @@ -419,7 +419,6 @@ export const getRepoImageSrc = (imageUrl: string | undefined, repoId: number, do // List of known public instances that don't require authentication const publicHostnames = [ 'github.com', - 'gitlab.com', 'avatars.githubusercontent.com', 'gitea.com', 'bitbucket.org',