Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Commit 2105985

Browse files
committed
Fix live tunnel port when proxyPort is taken
When starting the proxy we first check if proxyPort is free and otherwise we pick a random free port. The live tunnel would always connect to the port specified in the settings, so in that case it would start serving the wrong dev server on the .live domain. This makes sure we pass on the new port to the live tunnel if changed
1 parent 4709b6e commit 2105985

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/commands/dev/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async function startProxy(settings, addonUrls) {
133133
});
134134

135135
server.listen(port);
136-
return `http://localhost:${port}`;
136+
return { url: `http://localhost:${port}`, port };
137137
}
138138

139139
function startDevServer(settings, log) {
@@ -217,8 +217,6 @@ class DevCommand extends Command {
217217
};
218218
}
219219

220-
let url;
221-
222220
startDevServer(settings, this.log);
223221

224222
// serve functions from zip-it-and-ship-it
@@ -243,18 +241,18 @@ class DevCommand extends Command {
243241
settings.functionsPort = functionsPort;
244242
}
245243

246-
const proxyUrl = await startProxy(settings, addonUrls);
244+
let { url, port } = await startProxy(settings, addonUrls);
247245
if (!url) {
248246
url = proxyUrl;
249247
}
250248

251249
if (flags.live) {
252-
await waitPort({ port: settings.proxyPort });
250+
await waitPort({ port });
253251
const liveSession = await createTunnel(site.id, accessToken, this.log);
254252
url = liveSession.session_url;
255253
process.env.BASE_URL = url;
256254

257-
await connectTunnel(liveSession, accessToken, settings.port, this.log);
255+
await connectTunnel(liveSession, accessToken, port, this.log);
258256
}
259257

260258
// Todo hoist this telemetry `command` to CLI hook

0 commit comments

Comments
 (0)