@machhub-dev/sdk-ts 1.0.5 → 1.0.6

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.
@@ -126,12 +126,15 @@ class SDK {
126
126
  const application_id = config.application_id ||
127
127
  this.extractApplicationIDFromRuntimeID(envCfg.runtimeID);
128
128
  this.applicationID = application_id;
129
- // Determine the hostname - use window.location.hostname in browser, otherwise fallback to localhost
129
+ // Determine the hostname - use window.location in browser, otherwise fallback to localhost
130
130
  const hostname = typeof window !== 'undefined' ? window.location.hostname : 'localhost';
131
131
  const secured = typeof window !== 'undefined' ? window.location.protocol === 'https:' : false;
132
132
  let host = hostname;
133
133
  if (envCfg.hostingMode === 'port' || !envCfg.hostingMode) {
134
- host += `:${envCfg.port}`;
134
+ // In browser, use window.location.host which includes the port only when non-standard
135
+ // (e.g. "localhost:6190" for local dev, "machhub.dev" when behind a reverse proxy on 443)
136
+ // In non-browser environments, fall back to hostname:envCfg.port
137
+ host = typeof window !== 'undefined' ? window.location.host : `${hostname}:${envCfg.port}`;
135
138
  }
136
139
  else if (envCfg.hostingMode === 'path') {
137
140
  host += envCfg.pathHosted;
package/dist/sdk-ts.js CHANGED
@@ -123,12 +123,15 @@ export class SDK {
123
123
  const application_id = config.application_id ||
124
124
  this.extractApplicationIDFromRuntimeID(envCfg.runtimeID);
125
125
  this.applicationID = application_id;
126
- // Determine the hostname - use window.location.hostname in browser, otherwise fallback to localhost
126
+ // Determine the hostname - use window.location in browser, otherwise fallback to localhost
127
127
  const hostname = typeof window !== 'undefined' ? window.location.hostname : 'localhost';
128
128
  const secured = typeof window !== 'undefined' ? window.location.protocol === 'https:' : false;
129
129
  let host = hostname;
130
130
  if (envCfg.hostingMode === 'port' || !envCfg.hostingMode) {
131
- host += `:${envCfg.port}`;
131
+ // In browser, use window.location.host which includes the port only when non-standard
132
+ // (e.g. "localhost:6190" for local dev, "machhub.dev" when behind a reverse proxy on 443)
133
+ // In non-browser environments, fall back to hostname:envCfg.port
134
+ host = typeof window !== 'undefined' ? window.location.host : `${hostname}:${envCfg.port}`;
132
135
  }
133
136
  else if (envCfg.hostingMode === 'path') {
134
137
  host += envCfg.pathHosted;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@machhub-dev/sdk-ts",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "MACHHUB TYPESCRIPT SDK",
5
5
  "keywords": [
6
6
  "machhub",
package/src/sdk-ts.ts CHANGED
@@ -145,15 +145,18 @@ export class SDK {
145
145
 
146
146
  this.applicationID = application_id;
147
147
 
148
- // Determine the hostname - use window.location.hostname in browser, otherwise fallback to localhost
148
+ // Determine the hostname - use window.location in browser, otherwise fallback to localhost
149
149
  const hostname = typeof window !== 'undefined' ? window.location.hostname : 'localhost';
150
150
  const secured = typeof window !== 'undefined' ? window.location.protocol === 'https:' : false;
151
151
 
152
- let host = hostname
152
+ let host = hostname;
153
153
  if (envCfg.hostingMode === 'port' || !envCfg.hostingMode) {
154
- host += `:${envCfg.port}`;
154
+ // In browser, use window.location.host which includes the port only when non-standard
155
+ // (e.g. "localhost:6190" for local dev, "machhub.dev" when behind a reverse proxy on 443)
156
+ // In non-browser environments, fall back to hostname:envCfg.port
157
+ host = typeof window !== 'undefined' ? window.location.host : `${hostname}:${envCfg.port}`;
155
158
  } else if (envCfg.hostingMode === 'path') {
156
- host += envCfg.pathHosted
159
+ host += envCfg.pathHosted;
157
160
  }
158
161
 
159
162
  if (!config.httpUrl) {