entexto-cli 1.4.7 → 1.4.9
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/lib/commands/tunnel.js +28 -7
- package/package.json +1 -1
package/lib/commands/tunnel.js
CHANGED
|
@@ -46,13 +46,13 @@ module.exports = async function tunnel(opts) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const socket = ioClient(wsUrl, {
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
transports: ['
|
|
52
|
-
upgrade:
|
|
49
|
+
// WebSocket puro: manejo concurrente de assets (CSS/JS/imágenes en paralelo).
|
|
50
|
+
// Polling serializa los acks y causa 504 cuando hay muchos requests simultáneos.
|
|
51
|
+
transports: ['websocket'],
|
|
52
|
+
upgrade: false,
|
|
53
53
|
reconnection: true,
|
|
54
|
-
reconnectionDelay:
|
|
55
|
-
reconnectionDelayMax:
|
|
54
|
+
reconnectionDelay: 1000,
|
|
55
|
+
reconnectionDelayMax: 3000,
|
|
56
56
|
reconnectionAttempts: Infinity,
|
|
57
57
|
timeout: 20000,
|
|
58
58
|
});
|
|
@@ -130,7 +130,28 @@ module.exports = async function tunnel(opts) {
|
|
|
130
130
|
const chunks = [];
|
|
131
131
|
localRes.on('data', (chunk) => chunks.push(chunk));
|
|
132
132
|
localRes.on('end', () => {
|
|
133
|
-
|
|
133
|
+
let bodyBuf = Buffer.concat(chunks);
|
|
134
|
+
|
|
135
|
+
// Reescribir el host local → URL pública del túnel en respuestas de texto.
|
|
136
|
+
// Esto cubre el caso de Elementor/webpack cuyo __webpack_public_path__
|
|
137
|
+
// queda hardcodeado como cmy-rent-car.local (o el dominio local) en el JS.
|
|
138
|
+
const ct = (localRes.headers['content-type'] || '').toLowerCase();
|
|
139
|
+
const isText = /\b(javascript|css|html|json|xml|svg|text\/)/i.test(ct);
|
|
140
|
+
if (isText && publicUrl && bodyBuf.length > 0) {
|
|
141
|
+
const localOrigins = [
|
|
142
|
+
parsedTarget.origin, // http://cmy-rent-car.local
|
|
143
|
+
parsedTarget.origin.replace(/^http:/, 'https:'), // https://cmy-rent-car.local
|
|
144
|
+
parsedTarget.host, // cmy-rent-car.local
|
|
145
|
+
];
|
|
146
|
+
let text = bodyBuf.toString('utf8');
|
|
147
|
+
for (const origin of localOrigins) {
|
|
148
|
+
// Reemplazar como origen completo primero, luego como host suelto
|
|
149
|
+
text = text.split(origin).join(publicUrl);
|
|
150
|
+
}
|
|
151
|
+
bodyBuf = Buffer.from(text, 'utf8');
|
|
152
|
+
// Corregir Content-Length si venía fijo
|
|
153
|
+
localRes.headers['content-length'] = String(bodyBuf.length);
|
|
154
|
+
}
|
|
134
155
|
|
|
135
156
|
// Color del status
|
|
136
157
|
const status = localRes.statusCode;
|