Skip to content

Commit 0c23f67

Browse files
authored
Streaming fe server: bind to 0.0.0.0 in prod (#9115)
Fixing this problem with fly deploys ![image](https://github.com/redwoodjs/redwood/assets/30793/f2d6d342-854f-4e03-92a5-199d07e22ae8) But this isn't specific to Fly. Docker deploys in general usually require you to bind to 0.0.0.0. We already do this for regular non-streaming deploys. For example here https://github.com/redwoodjs/redwood/blob/8d0ab16aa1c39f1526e4213211608805735f6974/packages/cli/src/commands/serveBothHandler.js#L137
1 parent 8d0ab16 commit 0c23f67

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

packages/vite/src/runFeServer.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,25 @@ export async function runFeServer() {
119119
app.get(expressPathDef, routeHandler)
120120
}
121121

122-
app.listen(rwConfig.web.port)
123-
console.log(
124-
`Started production FE server on http://localhost:${rwConfig.web.port}`
122+
const server = app.listen(
123+
rwConfig.web.port,
124+
process.env.NODE_ENV === 'production' ? '0.0.0.0' : '::'
125125
)
126+
127+
server.on('listening', () => {
128+
let addressDetails = ''
129+
const address = server.address()
130+
131+
if (typeof address === 'string') {
132+
addressDetails = `(${address})`
133+
} else if (address && typeof address === 'object') {
134+
addressDetails = `(${address.address}:${address.port})`
135+
}
136+
137+
console.log(
138+
`Started production FE server on http://localhost:${rwConfig.web.port} ${addressDetails}`
139+
)
140+
})
126141
}
127142

128143
runFeServer()

0 commit comments

Comments
 (0)