diff --git a/src/app/api/ice/route.ts b/src/app/api/ice/route.ts index 781772f..a4d802b 100644 --- a/src/app/api/ice/route.ts +++ b/src/app/api/ice/route.ts @@ -5,9 +5,16 @@ import { setTurnCredentials } from '../../../coturn' const turnHost = process.env.TURN_HOST || '127.0.0.1' const stunServer = process.env.STUN_SERVER || 'stun:stun.l.google.com:19302' +// PATCH(gingermuffin): +// Create host and path to local peerjs +const peerjsHost = process.env.PEERJS_HOST || '127.0.0.1' +const peerjsPath = process.env.PEERJS_PATH || '/' + export async function POST(): Promise { if (!process.env.COTURN_ENABLED) { return NextResponse.json({ + host: peerjsHost, + path: peerjsPath, iceServers: [{ urls: stunServer }], }) } @@ -21,6 +28,8 @@ export async function POST(): Promise { await setTurnCredentials(username, password, ttl) return NextResponse.json({ + host: peerjsHost, + path: peerjsPath, iceServers: [ { urls: stunServer }, { diff --git a/src/components/WebRTCProvider.tsx b/src/components/WebRTCProvider.tsx index 7a52bf8..0153e87 100644 --- a/src/components/WebRTCProvider.tsx +++ b/src/components/WebRTCProvider.tsx @@ -34,13 +34,17 @@ async function getOrCreateGlobalPeer(): Promise { const response = await fetch('/api/ice', { method: 'POST', }) - const { iceServers } = await response.json() + const { host, path, iceServers } = await response.json() console.log('[WebRTCProvider] ICE servers:', iceServers) + console.log('[WebRTCProvider] host:', host) + console.log('[WebRTCProvider] path:', path) globalPeer = new Peer({ debug: 3, config: { iceServers, + host, + path, }, }) }