Skip to content

Commit e423b56

Browse files
authored
fix(gitlab): Properly handle auth for Gitlab project avatars (#345)
1 parent 1ea377e commit e423b56

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/backend/src/repoCompileUtils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ export const compileGitlabConfig = async (
121121
const isFork = project.forked_from_project !== undefined;
122122
const repoDisplayName = project.path_with_namespace;
123123
const repoName = path.join(repoNameRoot, repoDisplayName);
124-
124+
// project.avatar_url is not directly accessible with tokens; use the avatar API endpoint if available
125+
const avatarUrl = project.avatar_url
126+
? new URL(`/api/v4/projects/${project.id}/avatar`, hostUrl).toString()
127+
: null;
125128
logger.debug(`Found gitlab repo ${repoDisplayName} with webUrl: ${projectUrl}`);
126129

127130
const record: RepoData = {
@@ -132,7 +135,7 @@ export const compileGitlabConfig = async (
132135
webUrl: projectUrl,
133136
name: repoName,
134137
displayName: repoDisplayName,
135-
imageUrl: project.avatar_url,
138+
imageUrl: avatarUrl,
136139
isFork: isFork,
137140
isArchived: !!project.archived,
138141
org: {

packages/web/src/lib/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ export const getRepoImageSrc = (imageUrl: string | undefined, repoId: number, do
419419
// List of known public instances that don't require authentication
420420
const publicHostnames = [
421421
'github.com',
422-
'gitlab.com',
423422
'avatars.githubusercontent.com',
424423
'gitea.com',
425424
'bitbucket.org',

0 commit comments

Comments
 (0)