Skip to content

Commit 8d5664f

Browse files
authored
Start develop proxy before actual develop process (#25015)
This should fix Codesandbox sometimes exposing the wrong port. They simply expose the first port that is ever opened at `:80`, which before could be the random port assigned to the actual develop process. By always starting the proxy at `:8000` (or the user selected port), Codesandbox _should_ always expose that port at `:80`, resolving any incompatibilities.
1 parent b6ae337 commit 8d5664f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/gatsby/src/commands/develop.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ module.exports = async (program: IProgram): Promise<void> => {
116116
getRandomPort(),
117117
])
118118

119+
// NOTE(@mxstbr): We need to start the develop proxy before the develop process to ensure
120+
// codesandbox detects the right port to expose by default
121+
const proxy = startDevelopProxy({
122+
proxyPort: proxyPort,
123+
targetPort: developPort,
124+
program,
125+
})
126+
119127
const developProcess = new ControllableScript(`
120128
const cmd = require(${JSON.stringify(developProcessPath)});
121129
const args = ${JSON.stringify({
@@ -160,12 +168,6 @@ module.exports = async (program: IProgram): Promise<void> => {
160168
})
161169
}
162170

163-
const proxy = startDevelopProxy({
164-
proxyPort: proxyPort,
165-
targetPort: developPort,
166-
program,
167-
})
168-
169171
let unlock
170172
if (!isCI()) {
171173
unlock = await createServiceLock(program.directory, `developstatusserver`, {

0 commit comments

Comments
 (0)