teleportxr 1.0.28 → 1.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/signaling.js +17 -0
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "name": "teleportxr",
17
17
  "description": "Teleport Spatial Server on node.js",
18
- "version": "1.0.28",
18
+ "version": "1.0.29",
19
19
  "repository": {
20
20
  "type": "git",
21
21
  "url": "git+https://github.com/simul/teleport-nodejs.git"
package/signaling.js CHANGED
@@ -52,6 +52,7 @@ var desiredIP = "";
52
52
  var webRtcConnectionManager = null;
53
53
  var newClient=null;
54
54
  var disconnectClient=null;
55
+ var clientHostHeader = ""; // Store the first client's host header for resource URLs
55
56
  function startStreaming(signalingClient) {
56
57
  signalingClient.ChangeSignalingState(SignalingState.ACCEPTED);
57
58
  // And we send the WebSockets connect-response.
@@ -183,6 +184,17 @@ function OnWebSocket(ws, req) {
183
184
  " connected from " +
184
185
  signalingClient.ip_addr_port.toString()
185
186
  );
187
+
188
+ // Capture the Host header from the first client connection for resource URLs
189
+ // This allows us to auto-detect the server's public address
190
+ if (!clientHostHeader && req.headers) {
191
+ // Try to get the host from headers, preferring X-Forwarded-Host (for reverse proxies)
192
+ clientHostHeader = req.headers['x-forwarded-host'] || req.headers['host'] || '';
193
+ if (clientHostHeader) {
194
+ console.log("Auto-detected resource server host from client connection: " + clientHostHeader);
195
+ }
196
+ }
197
+
186
198
  //When the server runs behind a proxy like NGINX, the de-facto standard is to use the X-Forwarded-For header.
187
199
  //const ip = .headers['x-forwarded-for'].split(',')[0].trim();
188
200
 
@@ -273,3 +285,8 @@ exports.sendConfigMessage = function (clientID, msg) {
273
285
  };
274
286
 
275
287
  exports.signalingClients = signalingClients;
288
+
289
+ // Export function to retrieve the auto-detected client host header for resource URLs
290
+ exports.getClientHostHeader = function () {
291
+ return clientHostHeader;
292
+ };