diff --git a/docs/advanced-features/custom-server.md b/docs/advanced-features/custom-server.md index d476b52c08ed..d887c841025c 100644 --- a/docs/advanced-features/custom-server.md +++ b/docs/advanced-features/custom-server.md @@ -29,7 +29,10 @@ const { parse } = require('url') const next = require('next') const dev = process.env.NODE_ENV !== 'production' -const app = next({ dev }) +const hostname = 'localhost' +const port = 3000 +// when using middleware `hostname` and `port` must be provided below +const app = next({ dev, hostname, port }) const handle = app.getRequestHandler() app.prepare().then(() => { @@ -46,9 +49,9 @@ app.prepare().then(() => { } else { handle(req, res, parsedUrl) } - }).listen(3000, (err) => { + }).listen(port, (err) => { if (err) throw err - console.log('> Ready on http://localhost:3000') + console.log(`> Ready on http://${hostname}:${port}`) }) }) ``` diff --git a/docs/middleware.md b/docs/middleware.md index a660afd0f81c..327f61179675 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -76,18 +76,6 @@ Middleware runs directly after `redirects` and `headers`, before the first files Middleware uses a [strict runtime](/docs/api-reference/edge-runtime.md) that supports standard Web APIs like `fetch`. This works out of the box using `next start`, as well as on Edge platforms like Vercel, which use [Edge Functions](http://www.vercel.com/edge). -## Custom Server - -When using a custom server with middleware, you must specify the hostname and port when instantiating your `NextApp`. - -```ts -import next from 'next' -// ... -const port = process.env.PORT ? +process.env.PORT : 3000 -const dev = process.env.NODE_ENV !== 'production' -const app = next({ dev, customServer: true, hostname: 'localhost', port }) -``` - ## Related