Skip to content

Commit

Permalink
Streaming fe server: bind to 0.0.0.0 in prod (#9115)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Tobbe authored Sep 1, 2023
1 parent 8d0ab16 commit 0c23f67
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions packages/vite/src/runFeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,25 @@ export async function runFeServer() {
app.get(expressPathDef, routeHandler)
}

app.listen(rwConfig.web.port)
console.log(
`Started production FE server on http://localhost:${rwConfig.web.port}`
const server = app.listen(
rwConfig.web.port,
process.env.NODE_ENV === 'production' ? '0.0.0.0' : '::'
)

server.on('listening', () => {
let addressDetails = ''
const address = server.address()

if (typeof address === 'string') {
addressDetails = `(${address})`
} else if (address && typeof address === 'object') {
addressDetails = `(${address.address}:${address.port})`
}

console.log(
`Started production FE server on http://localhost:${rwConfig.web.port} ${addressDetails}`
)
})
}

runFeServer()

0 comments on commit 0c23f67

Please sign in to comment.