Skip to content

Commit 5fdc7e6

Browse files
authored
Preview branch fixes (#2126)
* SDK: auto-detect the branch using the VERCEL_GIT_COMMIT_REF env var * Waitpoint token completion with HTTP is now working
1 parent ea853b2 commit 5fdc7e6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

apps/webapp/app/routes/api.v1.waitpoints.tokens.$waitpointFriendlyId.callback.$hash.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
4343
environment: {
4444
select: {
4545
apiKey: true,
46+
parentEnvironment: {
47+
select: {
48+
apiKey: true,
49+
},
50+
},
4651
},
4752
},
4853
},
@@ -52,7 +57,13 @@ export async function action({ request, params }: ActionFunctionArgs) {
5257
return json({ error: "Waitpoint not found" }, { status: 404 });
5358
}
5459

55-
if (!verifyHttpCallbackHash(waitpoint.id, hash, waitpoint.environment.apiKey)) {
60+
if (
61+
!verifyHttpCallbackHash(
62+
waitpoint.id,
63+
hash,
64+
waitpoint.environment.parentEnvironment?.apiKey ?? waitpoint.environment.apiKey
65+
)
66+
) {
5667
return json({ error: "Invalid URL, hash doesn't match" }, { status: 401 });
5768
}
5869

packages/core/src/v3/apiClientManager/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ export class APIClientManagerAPI {
4646

4747
get branchName(): string | undefined {
4848
const config = this.#getConfig();
49-
const value = config?.previewBranch ?? getEnvVar("TRIGGER_PREVIEW_BRANCH") ?? undefined;
49+
const value =
50+
config?.previewBranch ??
51+
getEnvVar("TRIGGER_PREVIEW_BRANCH") ??
52+
getEnvVar("VERCEL_GIT_COMMIT_REF") ??
53+
undefined;
5054
return value ? value : undefined;
5155
}
5256

0 commit comments

Comments
 (0)