Hullo 馃憢
Currently if you want to bind your express instance to a specific IP you end up with something like this:
@Module({})
class ApplicationModule {}x
function createApp (
server: express.Application,
port: number,
address: string
): Promise<INestApplication> {
const app = NestFactory.create(ApplicationModule, server)
app.init()
return eventToPromise(server.listen(port, address), 'listening').then(
() => app
)
}
It would seem more ideal if NestApplication.listen() better reflected the options that ExpressAppliation.listen() takes? The above isn't so ideal given that it doesn't check if the nest application has already been initialised.
Hi @TobyColeman,
Definitely needed, marked as a todo.
@TobyColeman environment variables?
Hey ! You can use dotenv easily for that
Ah nice, I wasn't aware of an approach like this - https://stackoverflow.com/a/10714707 should have looked at the express docs a bit further. Cheers for noting that down @kamilmysliwiec!
@adrien2p could you show how?
I noticed this project at least presents a way to configure express directly:
Hi @TobyColeman,
Since @nestjs/core 4.0.4 the listen()
method accepts hostname
as a second argument :slightly_smiling_face:
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@TobyColeman environment variables?