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:
parent
1475491568
commit
8b24103d7f
9
errors/next-start-serverless.md
Normal file
9
errors/next-start-serverless.md
Normal 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 requests–this 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`.
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in a new issue