diff --git a/src/gateway/server-methods/browser.ts b/src/gateway/server-methods/browser.ts index c83ad947570..bda77ad98e4 100644 --- a/src/gateway/server-methods/browser.ts +++ b/src/gateway/server-methods/browser.ts @@ -20,6 +20,25 @@ type BrowserRequestParams = { timeoutMs?: number; }; +function resolveRequestedProfile(params: { + query?: Record; + body?: unknown; +}): string | undefined { + const queryProfile = + typeof params.query?.profile === "string" ? params.query.profile.trim() : undefined; + if (queryProfile) { + return queryProfile; + } + if (!params.body || typeof params.body !== "object") { + return undefined; + } + const bodyProfile = + "profile" in params.body && typeof params.body.profile === "string" + ? params.body.profile.trim() + : undefined; + return bodyProfile || undefined; +} + type BrowserProxyFile = { path: string; base64: string; @@ -187,7 +206,7 @@ export const browserHandlers: GatewayRequestHandlers = { query, body, timeoutMs, - profile: typeof query?.profile === "string" ? query.profile : undefined, + profile: resolveRequestedProfile({ query, body }), }; const res = await context.nodeRegistry.invoke({ nodeId: nodeTarget.nodeId,