publicRuntimeConfig shouldn’t be undefined on build
See original GitHub issueBug 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:
- Created 4 years ago
- Comments:35 (14 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I reproduced this bug on 9.4.2
I’ve tried v9.5.2 which should include #15777 and we’re still getting
undefinedback from anygetConfigcall it seems.