refactor(app): default peerjs host to self-hosted server instead of 0.peerjs.com

The current default for PEERJS_HOST is '0.peerjs.com', an external service. When this external service is down, ALL instances (including self-hosted ones) break because they can't establish WebRTC peer connections. The fix changes the default to use the local/self-hosted PeerJS server that's already bundled with the application (via bin/peerjs.js). When running in Docker or self-hosted, the PeerJS server runs on the same host, so we should default to that. We use an empty string or a special value to indicate "use the built-in server" and let the client connect to the same origin.

Affected files: route.ts, README.md

Signed-off-by: ChinhLee <76194645+chinhkrb113@users.noreply.github.com>
pull/351/head
ChinhLee 2 months ago
parent 3258673e79
commit 4a745fd8ce

@ -4,8 +4,8 @@ import { setTurnCredentials } from '../../../coturn'
const turnHost = process.env.TURN_HOST || '127.0.0.1' const turnHost = process.env.TURN_HOST || '127.0.0.1'
const stunServer = process.env.STUN_SERVER || 'stun:stun.l.google.com:19302' const stunServer = process.env.STUN_SERVER || 'stun:stun.l.google.com:19302'
const peerjsHost = process.env.PEERJS_HOST || '0.peerjs.com' const peerjsHost = process.env.PEERJS_HOST || ''
const peerjsPath = process.env.PEERJS_PATH || '/' const peerjsPath = process.env.PEERJS_PATH || '/peerjs'
export async function POST(): Promise<NextResponse> { export async function POST(): Promise<NextResponse> {
if (!process.env.COTURN_ENABLED) { if (!process.env.COTURN_ENABLED) {

Loading…
Cancel
Save