nstantpage-agent 0.8.15 → 0.8.16
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.
- package/dist/tunnel.js +11 -6
- package/package.json +1 -1
package/dist/tunnel.js
CHANGED
|
@@ -360,9 +360,9 @@ export class TunnelClient {
|
|
|
360
360
|
* Vite dev server and relay data bidirectionally through the tunnel.
|
|
361
361
|
* This enables Vite HMR to work through the cloud preview URL.
|
|
362
362
|
*/
|
|
363
|
-
handleWsOpenDevServer(wsId, url, protocol) {
|
|
364
|
-
const
|
|
365
|
-
const wsUrl = `ws://127.0.0.1:${
|
|
363
|
+
handleWsOpenDevServer(wsId, url, protocol, targetPort) {
|
|
364
|
+
const port = (targetPort && targetPort > 0) ? targetPort : this.devPort;
|
|
365
|
+
const wsUrl = `ws://127.0.0.1:${port}${url}`;
|
|
366
366
|
console.log(` [Tunnel] Opening HMR WS relay: ${wsId} → ${wsUrl}`);
|
|
367
367
|
const wsOptions = {};
|
|
368
368
|
const protocols = protocol ? protocol.split(',').map(p => p.trim()) : undefined;
|
|
@@ -472,7 +472,7 @@ export class TunnelClient {
|
|
|
472
472
|
break;
|
|
473
473
|
case 'ws-open':
|
|
474
474
|
if (msg.target === 'dev-server') {
|
|
475
|
-
this.handleWsOpenDevServer(msg.wsId, msg.url || '/', msg.protocol);
|
|
475
|
+
this.handleWsOpenDevServer(msg.wsId, msg.url || '/', msg.protocol, msg.targetPort);
|
|
476
476
|
}
|
|
477
477
|
else {
|
|
478
478
|
this.handleWsOpen(msg.wsId, msg.sessionId, msg.projectId);
|
|
@@ -502,9 +502,14 @@ export class TunnelClient {
|
|
|
502
502
|
* - Everything else → Dev server (Vite HMR, page loads, etc.)
|
|
503
503
|
*/
|
|
504
504
|
handleHttpRequest(request) {
|
|
505
|
-
const { url } = request;
|
|
505
|
+
const { url, headers } = request;
|
|
506
506
|
const isApiRequest = url.startsWith('/live/') || url === '/health';
|
|
507
|
-
|
|
507
|
+
// Use x-target-port header if present (multi-port tunneling), else fall back to default
|
|
508
|
+
const portHeader = headers?.['x-target-port'];
|
|
509
|
+
const overridePort = portHeader ? parseInt(String(portHeader), 10) : NaN;
|
|
510
|
+
const targetPort = isApiRequest
|
|
511
|
+
? this.options.apiPort
|
|
512
|
+
: (overridePort > 0 ? overridePort : this.devPort);
|
|
508
513
|
this.forwardToLocal(request, targetPort);
|
|
509
514
|
this.requestsForwarded++;
|
|
510
515
|
}
|
package/package.json
CHANGED