fix frontend

This commit is contained in:
root
2026-05-25 00:47:22 -04:00
parent 9bd0938951
commit 5ef9efb8a9
9 changed files with 95 additions and 73 deletions
@@ -1,16 +1,6 @@
import { Suspense } from 'react'
import { headers } from 'next/headers'
import { redirect } from 'next/navigation'
import SignInPageClient from '@/app/sign-in/[[...sign-in]]/SignInPageClient'
const MARKETPLACE_URL = process.env.NEXT_PUBLIC_MARKETPLACE_URL ?? 'http://localhost:3000'
function isInternalHost(host: string | null): boolean {
if (!host) return false
const hostname = host.split(':')[0]?.toLowerCase()
return ['host.docker.internal', 'dashboard', 'admin', 'api', 'marketplace'].includes(hostname)
}
export default async function SignInPage({
searchParams,
}: {
@@ -19,35 +9,6 @@ export default async function SignInPage({
const params = await searchParams
const embedded = params.embedded === '1'
if (!embedded) {
const requestHeaders = headers()
const host = requestHeaders.get('host')
const forwardedHost = requestHeaders.get('x-forwarded-host')
const proto = requestHeaders.get('x-forwarded-proto') ?? 'http'
const query = new URLSearchParams()
for (const [key, value] of Object.entries(params)) {
if (value === undefined) continue
if (Array.isArray(value)) {
for (const item of value) query.append(key, item)
} else {
query.set(key, value)
}
}
const marketplaceOrigin = new URL(MARKETPLACE_URL)
const publicHost = forwardedHost && !isInternalHost(forwardedHost)
? forwardedHost
: host && !isInternalHost(host)
? host
: null
if (!publicHost || publicHost === marketplaceOrigin.host) {
const destination = `${MARKETPLACE_URL}/sign-in${query.size ? `?${query.toString()}` : ''}`
redirect(destination)
}
}
return (
<Suspense fallback={null}>
<SignInPageClient embedded={embedded} />