Expect HTTP 204 for livekit support
This commit is contained in:
+8
-6
@@ -1,18 +1,20 @@
|
|||||||
const livekitEndpoint = (url: string, groupId: string) => {
|
const toHttpUrl = (url: string) =>
|
||||||
const httpUrl = url
|
url
|
||||||
.replace(/^wss:\/\//, "https://")
|
.replace(/^wss:\/\//, "https://")
|
||||||
.replace(/^ws:\/\//, "http://")
|
.replace(/^ws:\/\//, "http://")
|
||||||
.replace(/\/$/, "")
|
.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> => {
|
export const checkRelayHasLivekit = async (url: string): Promise<boolean> => {
|
||||||
const endpoint = livekitEndpoint(url, "nop")
|
const endpoint = livekitEndpoint(url)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Zooid returns 401 when livekit is configured and 404 if it is not.
|
|
||||||
const response = await fetch(endpoint)
|
const response = await fetch(endpoint)
|
||||||
return response.status === 401
|
return response.status === 204
|
||||||
} catch {
|
} catch {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user