Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming fe server: bind to 0.0.0.0 in prod #9115

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' : '::'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think no need to do this toggle maybe, since runFeServer is always production, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I had to specifically do NODE_ENV=production <command> when I ran this locally to test

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, so yeah, maybe if we always do 0.0.0.0 we don't need to toggle, if that's what you meant

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's what I mean :). Because runFeServer is only used for production serving, never in development!

Copy link
Member Author

@Tobbe Tobbe Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that could be said for all our serve commands in that case. We can think more about how we want to handle this when all this gets rewritten for the ongoing server-file stuff. So it works the same way everywhere

)

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()
Loading