Resolve apiUrl from the request via getApiUrlForRequest, and thread apiUrl into createAuthTokens. the 500 after merging dev was token signing now need an apiUrl for the JWT iss claim. I wasnt passing it until merge dev into

This commit is contained in:
Madison 2026-05-28 11:08:21 -05:00
parent acf292c79e
commit c3f665bc2b
2 changed files with 5 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import { claimPreviewPoolLease, fillPreviewPool } from "@/lib/preview-pool";
import { getApiUrlForRequest } from "@/lib/request-api-url";
import { createSmartRouteHandler } from "@/route-handlers/smart-route-handler";
import { runAsynchronouslyAndWaitUntil } from "@/utils/background-tasks";
import { yupNumber, yupObject, yupString } from "@stackframe/stack-shared/dist/schema-fields";
@ -25,8 +26,8 @@ export const POST = createSmartRouteHandler({
refresh_token: yupString().defined(),
}).defined(),
}),
async handler() {
const lease = await claimPreviewPoolLease();
async handler(_req, fullReq) {
const lease = await claimPreviewPoolLease({ apiUrl: getApiUrlForRequest(fullReq) });
runAsynchronouslyAndWaitUntil(fillPreviewPool({ maxCreate: 1 }));
return {

View File

@ -532,7 +532,7 @@ export async function fillPreviewPool(options?: { maxCreate?: number }): Promise
};
}
export async function claimPreviewPoolLease(): Promise<PreviewPoolLease> {
export async function claimPreviewPoolLease(options: { apiUrl: string }): Promise<PreviewPoolLease> {
assertPreviewModeEnabled();
const claimed = await claimReadyPreviewPoolProject() ?? await createPreviewPoolProject("leased");
@ -542,6 +542,7 @@ export async function claimPreviewPoolLease(): Promise<PreviewPoolLease> {
const { accessToken, refreshToken } = await createAuthTokens({
tenancy: internalTenancy,
projectUserId: claimed.userId,
apiUrl: options.apiUrl,
});
return {