initial commit
This commit is contained in:
18
app/composables/useWebRTCFailureReason.js
Normal file
18
app/composables/useWebRTCFailureReason.js
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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 }
|
||||
}
|
||||
Reference in New Issue
Block a user