Expect HTTP 204 for livekit support

This commit is contained in:
mplorentz
2026-03-12 10:42:35 -04:00
parent da45127c82
commit dc2d245f77
+8 -6
View File
@@ -1,18 +1,20 @@
const livekitEndpoint = (url: string, groupId: string) => {
const httpUrl = url
const toHttpUrl = (url: string) =>
url
.replace(/^wss:\/\//, "https://")
.replace(/^ws:\/\//, "http://")
.replace(/\/$/, "")
return `${httpUrl}/.well-known/nip29/livekit/${groupId}`
const livekitEndpoint = (url: string, groupId?: string) => {
const base = `${toHttpUrl(url)}/.well-known/nip29/livekit`
return groupId ? `${base}/${groupId}` : base
}
export const checkRelayHasLivekit = async (url: string): Promise<boolean> => {
const endpoint = livekitEndpoint(url, "nop")
const endpoint = livekitEndpoint(url)
try {
// Zooid returns 401 when livekit is configured and 404 if it is not.
const response = await fetch(endpoint)
return response.status === 401
return response.status === 204
} catch {
return false
}