When using next.js with a custom-server, publicRuntimeConfig is undefined in the client.
Check the logs on these Codesandboxes:
Working without a server: hello-world
Not working with a custom server: custom-server-express
publicRuntimeConfig to be as set in next.config.js.
What am I missing here? Is getConfig not supposed to work with a custom server? What would be the alternative?
This example works fine when clicking both console and terminal though https://codesandbox.io/s/rr1v861l2p
Urgh, my bad. Thanks.
I can't access the sandbox anymore, can someone post the solution?
Hey @timneutkens ! I'm also running into this issue where getConfig() returns an empty object when running a custom express server. Do you remember what the solution was?
it holds state in a singleton, the only reason it wouldn't work is if you have duplicated next inside node_modules or something 馃
Hmm yeah that's a possibility. I ended up going with Now build env and secrets instead and this library for dev. Works like a charm.
Most helpful comment
I can't access the sandbox anymore, can someone post the solution?