Skip to content

Commit

Permalink
fix: do not require hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
birme committed Jun 26, 2024
1 parent 6431728 commit 1e03a98
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/server/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
9 changes: 6 additions & 3 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 1e03a98

Please sign in to comment.