Files
kestrelos/app/composables/useWebRTCFailureReason.js
Madison Grubb b7046dc0e6 initial commit
2026-02-10 23:32:26 -05:00

19 lines
708 B
JavaScript

/**
* Fetch WebRTC failure reason (e.g. wrong host). Pure: same inputs → same output.
* @returns {Promise<{ wrongHost: { serverHostname: string, clientHostname: string } | null }>} Failure reason or null.
*/
export async function getWebRTCFailureReason() {
try {
const res = await $fetch('/api/live/debug-request-host', { credentials: 'include' })
const clientHostname = typeof window !== 'undefined' ? window.location.hostname : ''
const serverHostname = res?.hostname ?? ''
if (serverHostname && clientHostname && serverHostname !== clientHostname) {
return { wrongHost: { serverHostname, clientHostname } }
}
}
catch {
// ignore
}
return { wrongHost: null }
}