From b7c719349a0ee399a525937abb5905e50b0351f2 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 20 Apr 2022 10:58:29 +0200 Subject: [PATCH] fix(node-server): default production host to `0.0.0.0` --- docs/deploy/node.md | 2 +- src/runtime/entries/node-server.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/deploy/node.md b/docs/deploy/node.md index 950f96dad5..b8b9545a10 100644 --- a/docs/deploy/node.md +++ b/docs/deploy/node.md @@ -29,7 +29,7 @@ You can now deploy fully standalone `.output` directory to the hosting of your c You can customize server behavior using following environment variables: - `NITRO_PORT` or `PORT` (defaults to `3000`) -- `NITRO_HOST` or `HOST` (defaults to `'localhost'`) +- `NITRO_HOST` or `HOST` (defaults to `'0.0.0.0'`) - `NITRO_SSL_CERT` and `NITRO_SSL_KEY` - if both are present, this will launch the server in HTTPS mode. In the vast majority of cases, this should not be used other than for testing, and the Nitro server should be run behind a reverse proxy like nginx or Cloudflare which terminates SSL. diff --git a/src/runtime/entries/node-server.ts b/src/runtime/entries/node-server.ts index 8dece06d86..df8999a345 100644 --- a/src/runtime/entries/node-server.ts +++ b/src/runtime/entries/node-server.ts @@ -11,7 +11,7 @@ const key = process.env.NITRO_SSL_KEY const server = cert && key ? new HttpsServer({ key, cert }, nitroApp.h3App.nodeHandler) : new HttpServer(nitroApp.h3App.nodeHandler) const port = (destr(process.env.NITRO_PORT || process.env.PORT) || 3000) as number -const hostname = process.env.NITRO_HOST || process.env.HOST || 'localhost' +const hostname = process.env.NITRO_HOST || process.env.HOST || '0.0.0.0' // @ts-ignore server.listen(port, hostname, (err) => {