You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was happy to learn that next@9.2.2 introduced runtime config support for serverless targets:
Add support for runtimeConfigs in serverless mode: #10365
Make sure runtime config is set before any imports for serverless: #10386
Make sure runtime config works in dev mode for serverless targ…: #10402
However, after giving it a try I believe that there are some inconsistencies compared to the handling in server targets.
Describe the bug
When I specify my runtime configs in next.config.js, the process.env variables seem to be resolved during build time instead run time. Switching the target back to server makes the env vars resolve during runtime again.
git clone https://github.com/davidknezic/now-nextjs-serverless-runtime-config-issue yarn install yarn run next build MY_URI=uri MY_SECRET=secret yarn run next start
The index page will return Hello undefined undefined.
Expected behavior
I'd expect the page to return Hello secret uri when rendered on server, and Hello undefined uri when rendered on the client. (due to lack of server runtime config on client)
System information
Version of Next.js: 9.2.2
Additional context
Additionally, there is another issue when deploying that project to Zeit Now. While now dev seems ok, the productive deployment fails with
500
Duration: 37.84ms
Memory Used: 80 MB
ID: q8s27-1583164652631-baa9aa7de573
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15
2020-03-02T15:57:33.750Z 7e204fe5-a1fb-4266-89de-f0b72bdc4a05 ERROR TypeError: Cannot destructure property `serverRuntimeConfig` of 'undefined' or 'null'.
at IndexPage (/var/task/.next/serverless/pages/index.js:689:9)
at d (/var/task/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:498)
at $a (/var/task/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:39:16)
at a.b.render (/var/task/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:476)
at a.b.read (/var/task/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:18)
at renderToString (/var/task/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:54:364)
at render (/var/task/node_modules/next/dist/next-server/server/render.js:81:16)
at Object.renderPage (/var/task/node_modules/next/dist/next-server/server/render.js:346:16)
at Function.getInitialProps (/var/task/.next/serverless/pages/index.js:861:19)
at Object.loadGetInitialProps (/var/task/node_modules/next/dist/next-server/lib/utils.js:59:29)
The combination of target: serverless and the @now/next builder seem to return null or undefined from getConfig(). Unfortunately, I don't know how to properly test a productive Now deployment locally. I've committed the now.json to reproduce this additional issue, too.
The text was updated successfully, but these errors were encountered:
Hi, it looks like there was a mismatch with next/config and the new experimental-serverless-trace mode which is used when deploying on Now. I submitted a PR to address this, thanks for the report!
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
vercel
locked as resolved and limited conversation to collaborators
Jan 30, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug report
I was happy to learn that
next@9.2.2
introduced runtime config support forserverless
targets:Add support for runtimeConfigs in serverless mode: #10365
Make sure runtime config is set before any imports for serverless: #10386
Make sure runtime config works in dev mode for serverless targ…: #10402
However, after giving it a try I believe that there are some inconsistencies compared to the handling in
server
targets.Describe the bug
When I specify my runtime configs in
next.config.js
, theprocess.env
variables seem to be resolved during build time instead run time. Switching thetarget
back toserver
makes the env vars resolve during runtime again.To Reproduce
git clone https://github.com/davidknezic/now-nextjs-serverless-runtime-config-issue
yarn install
yarn run next build
MY_URI=uri MY_SECRET=secret yarn run next start
The index page will return
Hello undefined undefined
.Expected behavior
I'd expect the page to return
Hello secret uri
when rendered on server, andHello undefined uri
when rendered on the client. (due to lack of server runtime config on client)System information
Additional context
Additionally, there is another issue when deploying that project to Zeit Now. While
now dev
seems ok, the productive deployment fails withThe combination of
target: serverless
and the@now/next
builder seem to returnnull
orundefined
fromgetConfig()
. Unfortunately, I don't know how to properly test a productive Now deployment locally. I've committed thenow.json
to reproduce this additional issue, too.The text was updated successfully, but these errors were encountered: