fix signin

This commit is contained in:
root
2026-05-17 16:46:57 -04:00
parent 5bc6772f64
commit 8be98062b2
@@ -1,14 +1,15 @@
'use client' 'use client'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { resolveBrowserAppUrl } from '@/lib/appUrls'
import { useMarketplacePreferences } from './MarketplaceShell' import { useMarketplacePreferences } from './MarketplaceShell'
type FrameId = 'sign-in' type FrameId = 'sign-in'
const frameConfig: Record<FrameId, { label: string; port: number; path: string }> = { const frameConfig: Record<FrameId, { label: string; appUrl: string; path: string }> = {
'sign-in': { 'sign-in': {
label: 'Sign in', label: 'Sign in',
port: 3001, appUrl: process.env.NEXT_PUBLIC_DASHBOARD_URL ?? 'http://localhost:3001/dashboard',
path: '/dashboard/sign-in', path: '/dashboard/sign-in',
}, },
} }
@@ -30,16 +31,16 @@ function getDefaultFramePath(target: FrameId) {
return frameConfig[target].path return frameConfig[target].path
} }
function withPort(port: number, path: string) { function buildFrameUrl(appUrl: string, path: string) {
if (typeof window === 'undefined') return path if (typeof window === 'undefined') return path
const url = new URL(window.location.href) const resolvedAppUrl = resolveBrowserAppUrl(appUrl)
url.port = String(port) const appBase = new URL(resolvedAppUrl, window.location.origin)
const target = new URL(path, url.origin) const target = new URL(path, window.location.origin)
url.pathname = target.pathname appBase.pathname = target.pathname
url.search = target.search appBase.search = target.search
url.hash = '' appBase.hash = ''
return url.toString() return appBase.toString()
} }
export default function WorkspaceFrame({ target }: { target: FrameId }) { export default function WorkspaceFrame({ target }: { target: FrameId }) {
@@ -74,11 +75,11 @@ export default function WorkspaceFrame({ target }: { target: FrameId }) {
}, []) }, [])
useEffect(() => { 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('theme', theme)
nextUrl.searchParams.set('lang', language) nextUrl.searchParams.set('lang', language)
setSrc(nextUrl.toString()) setSrc(nextUrl.toString())
}, [config.port, framePath, language, theme]) }, [config.appUrl, framePath, language, theme])
return ( return (
<main className="bg-stone-950" style={{ minHeight: frameHeight }}> <main className="bg-stone-950" style={{ minHeight: frameHeight }}>