diff --git a/packages/server/src/api.ts b/packages/server/src/api.ts index 2f4628b..9abf7b2 100644 --- a/packages/server/src/api.ts +++ b/packages/server/src/api.ts @@ -67,7 +67,7 @@ export default function(fastify: FastifyInstance, opts, done) { reply.headers({ "Content-Type": "application/sdp", - "Location": `${opts.instance.getServerAddress()}${opts.prefix}/whip/${type}/${resource.getId()}`, + "Location": `${opts.instance.getServerAddress()||''}${opts.prefix}/whip/${type}/${resource.getId()}`, }); const links = addIceLinks(resource.getIceServers(), request.headers["authorization"]) .concat(addProtocolExtensions(resource)); diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 2aad655..5647e89 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -40,7 +40,7 @@ export class WHIPEndpoint { this.extPort = opts?.extPort || this.port; this.interfaceIp = opts?.interfaceIp || "0.0.0.0"; this.useHttps = !!(opts?.https); - this.hostname = opts?.hostname || "localhost"; + this.hostname = opts?.hostname; this.enabledWrtcPlugins = opts?.enabledWrtcPlugins || []; this.iceServers = opts?.iceServers || []; this.tls = opts?.tls; @@ -118,8 +118,11 @@ export class WHIPEndpoint { return this.iceServers; } - getServerAddress(): string { - return (this.useHttps ? "https" : "http") + "://" + this.hostname + ":" + this.extPort; + getServerAddress(): string | undefined { + if (this.hostname) { + return (this.useHttps ? "https" : "http") + "://" + this.hostname + ":" + this.extPort; + } + return undefined; } listen() {