Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/main/lib/videoGatewayOrigin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { session } from 'electron'

// WHEP endpoint of the NethVoice video gateway (MediaMTX)
const VIDEO_GATEWAY_URLS = [
'https://*/streaming-gw/*',
'http://*/streaming-gw/*',
]

/**
* The pages of NethLink are loaded from file://, so their requests carry no
* Origin header while Chromium marks them as cross-site. The video gateway
* refuses a cross-site request without a valid origin before checking its
* token, and the door phone video is never shown. Send the requests to the
* gateway with the origin of the gateway itself: the access is still granted
* by the token of the request only.
*/
export function attachVideoGatewayOrigin() {
session.defaultSession.webRequest.onBeforeSendHeaders(
{ urls: VIDEO_GATEWAY_URLS },
(details, callback) => {
const requestHeaders = { ...details.requestHeaders }
const hasOrigin = Object.keys(requestHeaders).some(
(name) => name.toLowerCase() === 'origin',
)
if (!hasOrigin) {
requestHeaders['Origin'] = new URL(details.url).origin
}
callback({ requestHeaders })
},
)
}
2 changes: 2 additions & 0 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import Backend from 'i18next-fs-backend/cjs'
import { uniq } from 'lodash'
import { Registry } from 'rage-edit'
import { useNethVoiceAPI } from '@shared/useNethVoiceAPI'
import { attachVideoGatewayOrigin } from './lib/videoGatewayOrigin'

// get app parameter
const params = process.argv
Expand Down Expand Up @@ -297,6 +298,7 @@ function attachOnReadyProcess() {
new SplashScreenController()
new TrayController()
new ScreenSharePickerController()
attachVideoGatewayOrigin()

// I display the splashscreen when the splashscreen component is correctly loaded.
SplashScreenController.instance.window.addOnBuildListener(() => {
Expand Down
Loading