1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Throw Error When Running next start on Serverless Build (#6166)

Fixes #6144
This commit is contained in:
Connor Davis 2019-01-29 06:42:07 -06:00 committed by Tim Neutkens
parent 1475491568
commit 8b24103d7f
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,9 @@
# Using `next start` with `target` not set to `server`
#### Why This Error Occurred
Next.js can only handle running a server when the `target` is set to `server` (this is the default value). A serverless build, for instance, has no handler for requeststhis is usually implemented by a hosting provider.
#### Possible Ways to Fix It
Use a different handler than `next start` when testing a serverless **production** build, otherwise just use `next dev`.

View file

@ -47,7 +47,9 @@ export default class Server {
// Only serverRuntimeConfig needs the default
// publicRuntimeConfig gets it's default in client/index.js
const {serverRuntimeConfig = {}, publicRuntimeConfig, assetPrefix, generateEtags} = this.nextConfig
const {serverRuntimeConfig = {}, publicRuntimeConfig, assetPrefix, generateEtags, target} = this.nextConfig
if (process.env.NODE_ENV === 'production' && target !== 'server') throw new Error('Cannot start server when target is not server. https://err.sh/zeit/next.js/next-start-serverless')
this.buildId = this.readBuildId()
this.renderOpts = {