import { getRequestHost, getRequestURL } from 'h3'
import { requireAuth } from '../../utils/authHelpers.js'

/**
 * Diagnostic: returns the host the server sees for this request.
 * Use from the phone or laptop to verify the server receives the expected hostname (e.g. LAN IP).
 * Auth required.
 */
export default defineEventHandler((event) => {
  requireAuth(event)
  return {
    host: getRequestHost(event),
    hostname: getRequestURL(event).hostname,
  }
})
