diff --git a/packages/app/server/api/repo/commits.get.ts b/packages/app/server/api/repo/commits.get.ts index 28bfaa34..472f8d87 100644 --- a/packages/app/server/api/repo/commits.get.ts +++ b/packages/app/server/api/repo/commits.get.ts @@ -28,6 +28,20 @@ interface CommitMeta { branch: string | null; } +function getCommitPanelOrigin(event: H3Event) { + const requestUrl = getRequestURL(event); + const headers = getHeaders(event); + const host = + headers["x-forwarded-host"]?.split(",")[0]?.trim() || + headers.host?.split(",")[0]?.trim() || + requestUrl.host; + const protocol = + headers["x-forwarded-proto"]?.split(",")[0]?.trim() || + requestUrl.protocol.replace(":", ""); + + return `${protocol}://${host}`; +} + async function getCommitMetadata( installation: Awaited>, owner: string, @@ -237,7 +251,7 @@ export default defineEventHandler(async (event) => { const nextCursor = hasNextPage ? String(page + 1) : null; const totalCount = releases.length; const totalPages = Math.max(1, Math.ceil(totalCount / perPage)); - const origin = getRequestURL(event).origin; + const origin = getCommitPanelOrigin(event); const commitMetadata = await getCommitMetadata( installation, query.owner,