diff --git a/apps/webapp/app/routes/api.v1.waitpoints.tokens.$waitpointFriendlyId.callback.$hash.ts b/apps/webapp/app/routes/api.v1.waitpoints.tokens.$waitpointFriendlyId.callback.$hash.ts index 0dc5c26111..fd29764d65 100644 --- a/apps/webapp/app/routes/api.v1.waitpoints.tokens.$waitpointFriendlyId.callback.$hash.ts +++ b/apps/webapp/app/routes/api.v1.waitpoints.tokens.$waitpointFriendlyId.callback.$hash.ts @@ -43,6 +43,11 @@ export async function action({ request, params }: ActionFunctionArgs) { environment: { select: { apiKey: true, + parentEnvironment: { + select: { + apiKey: true, + }, + }, }, }, }, @@ -52,7 +57,13 @@ export async function action({ request, params }: ActionFunctionArgs) { return json({ error: "Waitpoint not found" }, { status: 404 }); } - if (!verifyHttpCallbackHash(waitpoint.id, hash, waitpoint.environment.apiKey)) { + if ( + !verifyHttpCallbackHash( + waitpoint.id, + hash, + waitpoint.environment.parentEnvironment?.apiKey ?? waitpoint.environment.apiKey + ) + ) { return json({ error: "Invalid URL, hash doesn't match" }, { status: 401 }); } diff --git a/packages/core/src/v3/apiClientManager/index.ts b/packages/core/src/v3/apiClientManager/index.ts index daaf354e0b..b4e9676fd8 100644 --- a/packages/core/src/v3/apiClientManager/index.ts +++ b/packages/core/src/v3/apiClientManager/index.ts @@ -46,7 +46,11 @@ export class APIClientManagerAPI { get branchName(): string | undefined { const config = this.#getConfig(); - const value = config?.previewBranch ?? getEnvVar("TRIGGER_PREVIEW_BRANCH") ?? undefined; + const value = + config?.previewBranch ?? + getEnvVar("TRIGGER_PREVIEW_BRANCH") ?? + getEnvVar("VERCEL_GIT_COMMIT_REF") ?? + undefined; return value ? value : undefined; }