Skip to content

Commit 95fa09e

Browse files
committed
fix: localhost in ssr page payload
1 parent 1051145 commit 95fa09e

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

packages/app/server/api/repo/commits.get.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ interface CommitMeta {
2828
branch: string | null;
2929
}
3030

31+
function getCommitPanelOrigin(event: H3Event) {
32+
const requestUrl = getRequestURL(event);
33+
const headers = getHeaders(event);
34+
const host =
35+
headers["x-forwarded-host"]?.split(",")[0]?.trim() ||
36+
headers.host?.split(",")[0]?.trim() ||
37+
requestUrl.host;
38+
const protocol =
39+
headers["x-forwarded-proto"]?.split(",")[0]?.trim() ||
40+
requestUrl.protocol.replace(":", "");
41+
42+
return `${protocol}://${host}`;
43+
}
44+
3145
async function getCommitMetadata(
3246
installation: Awaited<ReturnType<typeof useOctokitInstallation>>,
3347
owner: string,
@@ -237,7 +251,7 @@ export default defineEventHandler(async (event) => {
237251
const nextCursor = hasNextPage ? String(page + 1) : null;
238252
const totalCount = releases.length;
239253
const totalPages = Math.max(1, Math.ceil(totalCount / perPage));
240-
const origin = getRequestURL(event).origin;
254+
const origin = getCommitPanelOrigin(event);
241255
const commitMetadata = await getCommitMetadata(
242256
installation,
243257
query.owner,

0 commit comments

Comments
 (0)