feat(webrtc): integrate Cloudflare TURN/STUN servers
- Add backend endpoint to fetch ICE server credentials from Cloudflare - Implement dynamic ICE server configuration in frontend - Add fallback to public STUN servers when Cloudflare unavailable - Create comprehensive test suite for WebRTC API endpoint - Update environment configuration with Cloudflare TURN credentials Backend changes: - New route: GET /api/webrtc/ice-servers (authenticated) - Fetches temporary credentials from Cloudflare API with 24h TTL - Returns formatted ICE servers for RTCPeerConnection - Graceful fallback to Google STUN servers on errors Frontend changes: - Remove hardcoded ICE servers from useWebRTC hook - Fetch ICE servers dynamically from backend on mount - Store servers in ref for peer connection initialization - Add webrtcAPI service for backend communication Tests: - 9 comprehensive tests covering all scenarios - 100% coverage for webrtc.js route - Tests authentication, success, and all fallback scenarios
This commit is contained in:
@@ -516,4 +516,14 @@ export const publicAPI = {
|
||||
},
|
||||
};
|
||||
|
||||
// WebRTC API
|
||||
export const webrtcAPI = {
|
||||
async getIceServers() {
|
||||
const data = await fetchAPI('/webrtc/ice-servers', {
|
||||
method: 'GET',
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
|
||||
export { ApiError };
|
||||
|
||||
Reference in New Issue
Block a user