Skip to content

Commit 7a9d216

Browse files
committed
feat: support f2fs:// for HTTPS in F2F_APP
f2f:// maps to http (local dev), f2fs:// maps to https (production). Mirrors the ws:// vs wss:// convention.
1 parent f8fc8ac commit 7a9d216

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

lib/server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface ServerOptions {
2222

2323
// Optional:
2424
alternativeServer?: string | false // If not set will try to use RTCV_ALTERNATIVE_SERVER env variable, if set to false will disable alternative server
25-
f2fApp?: string | false // If not set will try to use F2F_APP env variable (format: f2f://keyId:keySecret@host), if set to false will disable app mode
25+
f2fApp?: string | false // If not set will try to use F2F_APP env variable (format: f2f[s]://keyId:keySecret@host, s = https), if set to false will disable app mode
2626
f2fAlternativeApp?: string | false // If not set will try to use F2F_ALTERNATIVE_APP env variable (same format), if set to false will disable alternative app
2727
port?: number // If not set will try to use SERVER_PORT or default to: 3000
2828
noHealthChecks?: boolean // If set to true will disable health checks on the RT-CV server
@@ -143,19 +143,19 @@ export class Server {
143143
options.skipAliveCheck ??
144144
this.mightGetEnv("SKIP_ALIVE_CHECK").toLowerCase() === "true"
145145

146-
// Check for F2F_APP mode (format: f2f://keyId:keySecret@host)
146+
// Check for F2F_APP mode (format: f2f:// or f2fs:// for http/https)
147147
const f2fAppRaw = options.f2fApp || this.mightGetEnv("F2F_APP")
148148
if (f2fAppRaw) {
149149
const f2fApp = new URL(f2fAppRaw)
150150
if (!f2fApp.username || !f2fApp.password) {
151151
console.log(
152-
"F2F_APP must contain credentials, e.g. f2f://keyId:keySecret@app.first2find.nl",
152+
"F2F_APP must contain credentials, e.g. f2fs://keyId:keySecret@app.first2find.nl",
153153
)
154154
process.exit(1)
155155
}
156156

157157
this.isAppMode = true
158-
this.appBaseUrl = "http://" + f2fApp.host
158+
this.appBaseUrl = (f2fApp.protocol === "f2fs:" ? "https://" : "http://") + f2fApp.host
159159
this.appTokenManager = new AppTokenManager({
160160
url: this.appBaseUrl,
161161
keyId: f2fApp.username,
@@ -227,7 +227,7 @@ export class Server {
227227
const altApp = new URL(altAppRaw)
228228
if (!altApp.username || !altApp.password) {
229229
console.log(
230-
"F2F_ALTERNATIVE_APP must contain credentials, e.g. f2f://keyId:keySecret@app.first2find.nl",
230+
"F2F_ALTERNATIVE_APP must contain credentials, e.g. f2fs://keyId:keySecret@app.first2find.nl",
231231
)
232232
process.exit(1)
233233
}

0 commit comments

Comments
 (0)