Can serverRuntimeConfig be used when in serverless mode?
The following code:
import getConfig from 'next/config';
const { serverRuntimeConfig } = getConfig();
returns
Cannot destructure property serverRuntimeConfig of 'undefined' or 'null'
For publicRuntimeConfig there is an error saying that it can't be used but not for that one.
https://github.com/zeit/next.js#runtime-configuration
Warning: Note that this option is not available when using target: 'serverless'
Warning: .................................................
The next/config module gives your app access to the publicRuntimeConfig and serverRuntimeConfig stored in your next.config.js.
https://github.com/zeit/next.js#runtime-configuration
Warning: Note that this option is not available when using target: 'serverless'
Warning: .................................................
The next/config module gives your app access to the publicRuntimeConfig and serverRuntimeConfig stored in your next.config.js.
I've the same error and I don't use target: serverless
https://github.com/zeit/next.js#runtime-configuration
Warning: Note that this option is not available when using target: 'serverless'
Warning: .................................................
The next/config module gives your app access to the publicRuntimeConfig and serverRuntimeConfig stored in your next.config.js.
I've the same error and I don't use
target: serverless
Once deployed on Now or locally?
https://github.com/zeit/next.js#runtime-configuration
Warning: Note that this option is not available when using target: 'serverless'
Warning: .................................................
The next/config module gives your app access to the publicRuntimeConfig and serverRuntimeConfig stored in your next.config.js.
I've the same error and I don't use
target: serverlessOnce deployed on Now or locally?
locally. Only I already don't use this feature. I found solution with simple env configuration.
If you are using a custom server, be sure to use getConfig only after initialisation of the Next app:
import getConfig from 'next/config';
console.log(getConfig()) // undefined - no config initialised yet
const app = next({ ... })
console.log(getConfig()) // this works
If you are using a custom server, be sure to use
getConfigonly after initialisation of the Next app:import getConfig from 'next/config'; console.log(getConfig()) // undefined - no config initialised yet const app = next({ ... }) console.log(getConfig()) // this works
Thank you for your contribution! However I found out that when you deploy with Now, even if you specify target: server in the config, you still get a serverless deployment. So I don't know we can even use custom servers.
When deploying to ZEIT Now the target is forced to serverless -- you cannot deploy a server Next.js app to ZEIT Now!