diff --git a/server/api/api.go b/server/api/api.go index 5087c13..0ae6910 100644 --- a/server/api/api.go +++ b/server/api/api.go @@ -6,7 +6,7 @@ import ( "net/url" woomMiddleware "woom/server/api/middleware" - "woom/server/api/v1" + v1 "woom/server/api/v1" "woom/server/helper" "woom/static" @@ -49,6 +49,8 @@ func NewApi(rdb *redis.Client, secret string, live777Url string, live777Token st r.Post("/room/{roomId}/stream", handle.CreateRoomStream) r.Patch("/room/{roomId}/stream/{streamId}", handle.UpdateRoomStream) r.Delete("/room/{roomId}/stream/{streamId}", handle.DestroyRoomStream) + r.HandleFunc("/whip/{uuid}", handler(proxy, live777Url, live777Token)) + r.HandleFunc("/whep/{uuid}", handler(proxy, live777Url, live777Token)) }) r.Post("/user/", handle.CreateUser) @@ -56,9 +58,6 @@ func NewApi(rdb *redis.Client, secret string, live777Url string, live777Token st //r.Post("/room/{roomId}/message", handle.CreateMessage) //r.Get("/room/{roomId}/message", handle.ShowMessage) - r.HandleFunc("/whip/{uuid}", handler(proxy, live777Url, live777Token)) - r.HandleFunc("/whep/{uuid}", handler(proxy, live777Url, live777Token)) - r.Handle("/*", http.StripPrefix("/", http.FileServer(helper.NewSinglePageApp("index.html", http.FS(static.Dist))))) return r } diff --git a/webapp/components/use/whip.ts b/webapp/components/use/whip.ts index d63b8db..abb2312 100644 --- a/webapp/components/use/whip.ts +++ b/webapp/components/use/whip.ts @@ -1,6 +1,6 @@ import { useSyncExternalStore } from 'react' import { event, Context, Data } from './whxp' -import { Stream, StreamState } from '../../lib/api' +import { Stream, StreamState, token } from '../../lib/api' import { WHIPClient } from 'whip-whep/whip' import { deviceNone, @@ -188,7 +188,7 @@ class WHIPContext extends Context { try { const url = location.origin + `/whip/${id}` - await client.publish(pc, url) + await client.publish(pc, url, token) } catch (e) { console.log(e) userStatus.state = StreamState.Failed diff --git a/webapp/lib/api.ts b/webapp/lib/api.ts index ca72dae..28b7171 100644 --- a/webapp/lib/api.ts +++ b/webapp/lib/api.ts @@ -132,6 +132,8 @@ export { delStream, StreamState, + + token, } export type {