diff --git a/apps/marketplace/src/components/WorkspaceFrame.tsx b/apps/marketplace/src/components/WorkspaceFrame.tsx index d738f13..2016f11 100644 --- a/apps/marketplace/src/components/WorkspaceFrame.tsx +++ b/apps/marketplace/src/components/WorkspaceFrame.tsx @@ -1,14 +1,15 @@ 'use client' import { useEffect, useState } from 'react' +import { resolveBrowserAppUrl } from '@/lib/appUrls' import { useMarketplacePreferences } from './MarketplaceShell' type FrameId = 'sign-in' -const frameConfig: Record = { +const frameConfig: Record = { 'sign-in': { label: 'Sign in', - port: 3001, + appUrl: process.env.NEXT_PUBLIC_DASHBOARD_URL ?? 'http://localhost:3001/dashboard', path: '/dashboard/sign-in', }, } @@ -30,16 +31,16 @@ function getDefaultFramePath(target: FrameId) { return frameConfig[target].path } -function withPort(port: number, path: string) { +function buildFrameUrl(appUrl: string, path: string) { if (typeof window === 'undefined') return path - const url = new URL(window.location.href) - url.port = String(port) - const target = new URL(path, url.origin) - url.pathname = target.pathname - url.search = target.search - url.hash = '' - return url.toString() + const resolvedAppUrl = resolveBrowserAppUrl(appUrl) + const appBase = new URL(resolvedAppUrl, window.location.origin) + const target = new URL(path, window.location.origin) + appBase.pathname = target.pathname + appBase.search = target.search + appBase.hash = '' + return appBase.toString() } export default function WorkspaceFrame({ target }: { target: FrameId }) { @@ -74,11 +75,11 @@ export default function WorkspaceFrame({ target }: { target: FrameId }) { }, []) useEffect(() => { - const nextUrl = new URL(withPort(config.port, framePath)) + const nextUrl = new URL(buildFrameUrl(config.appUrl, framePath)) nextUrl.searchParams.set('theme', theme) nextUrl.searchParams.set('lang', language) setSrc(nextUrl.toString()) - }, [config.port, framePath, language, theme]) + }, [config.appUrl, framePath, language, theme]) return (