import { headers } from 'next/headers'
import { redirect } from 'next/navigation'
import { resolveServerAppUrl } from '@/lib/appUrls'

export default async function AdminLoginPage() {
  const requestHeaders = await headers()
  const dashboardUrl = resolveServerAppUrl(
    process.env.NEXT_PUBLIC_DASHBOARD_URL ?? 'http://localhost:3000/dashboard',
    requestHeaders.get('host'),
    requestHeaders.get('x-forwarded-proto'),
  )
  redirect(`${dashboardUrl}/sign-in?portal=admin&next=/dashboard`)
}
