Expect HTTP 204 for livekit support
This commit is contained in:
+8
-6
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user