Skip to content

Commit

Permalink
docs: remix serve PORT
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanflorence committed Aug 16, 2023
1 parent 8a2ca03 commit a68ea55
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions docs/other-api/serve.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: "@remix-run/serve"
toc: false
order: 3
---

Expand All @@ -12,6 +11,24 @@ Remix is designed for you to own your server, but if you don't want to set one u
remix-serve <server-build-path>
```

## `PORT` environment variable

You can change the port of the server with an environment variable.

```sh
PORT=4000 npx remix-serve <server-build-path>
```

## `HOST` environment variable

You can configure the hostname for your Express app via `process.env.HOST` and that value will be passed to the internal [`app.listen`][express-listen] method when starting the server.

```sh
HOST=127.0.0.1 npx remix-serve build/
```

## Development Environment

Depending on `process.env.NODE_ENV`, the server will boot in development or production mode.

The `server-build-path` needs to point to the `serverBuildDirectory` defined in `remix.config.js`.
Expand Down Expand Up @@ -59,14 +76,6 @@ In development, `remix-serve` will ensure the latest code is run by purging the

In production this doesn't happen. The server boots up and that's the end of it.

## `HOST` environment variable

You can configure the hostname for your Express app via `process.env.HOST` and that value will be passed to the internal [`app.listen`][express-listen] method when starting the server.

```sh
HOST=127.0.0.1 npx remix-serve build/
```

[remix-run-express]: adapter#createrequesthandler
[remember]: ./dev-v2#keeping-in-memory-server-state-across-rebuilds
[express-listen]: https://expressjs.com/en/api.html#app.listen

0 comments on commit a68ea55

Please sign in to comment.