question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

publicRuntimeConfig shouldn’t be undefined on build

See original GitHub issue

Bug report

Describe the bug

v8.1.1-canary.62 (or maybe 3aed76fad857b518a31675987e8c79f6f1afccde) (re-)introduces an issue with how I use (and recommend how to use) https://github.com/tusbar/next-runtime-dotenv.

To Reproduce

This breaks on build as publicRuntimeConfig is undefined at build time:

const {
  publicRuntimeConfig: {MY_API_URL}
} = getConfig()

Expected behavior

publicRuntimeConfig used to be {} at build time.

System information

  • OS: macOS
  • Version of Next.js: 8.1.1-canary.62

Additional context

This is not the first time this breaks, maybe it would be nice to add a test. It used to work fine with 8.0.4, it’s broken in 8.1.0 and used to work fine in canary before 8.1.1-canary.62. Broken in 9.0 as well.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:35 (14 by maintainers)

github_iconTop GitHub Comments

31reactions
jtaoxcommented, Jun 13, 2020

I reproduced this bug on 9.4.2

10reactions
Multiplycommented, Aug 24, 2020

I’ve tried v9.5.2 which should include #15777 and we’re still getting undefined back from any getConfig call it seems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

publicRuntimeConfig in next.config.js is always undefined ...
I use next build command defore deploy for production. After build I use pm2 start with my custom file server.js but just next...
Read more >
publicRuntimeConfig undefined when using Storybook ...
publicRuntimeConfig is setup for us automatically in a Next app, but that doesn't happen when our code gets bundled into Storybook so we ......
Read more >
next - npm
The next/config module gives your app access to the publicRuntimeConfig and serverRuntimeConfig stored in your next.config.js . Place any server ...
Read more >
webpack/webpack - Gitter
Hey, would someone be able to help me figure out how to import some legacy .js files properly in webpack? The 'modules' are...
Read more >
Facebook debugger does not pick up Next js next-seo ...
APP_DESCRIPTION; const appName = publicRuntimeConfig. ... I got the impression that this shouldn't be done with getServerSideProps.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found