Next.js: next/config not working on custom server

Created on 18 Oct 2018  路  6Comments  路  Source: vercel/next.js

Bug report

Describe the bug

When using next.js with a custom-server, publicRuntimeConfig is undefined in the client.

To Reproduce

Check the logs on these Codesandboxes:
Working without a server: hello-world
Not working with a custom server: custom-server-express

Expected behavior

publicRuntimeConfig to be as set in next.config.js.

System information

  • Version of Next.js: 7.0.2

What am I missing here? Is getConfig not supposed to work with a custom server? What would be the alternative?

Most helpful comment

I can't access the sandbox anymore, can someone post the solution?

All 6 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

formula349 picture formula349  路  3Comments

jesselee34 picture jesselee34  路  3Comments

ghost picture ghost  路  3Comments

knipferrc picture knipferrc  路  3Comments

DvirSh picture DvirSh  路  3Comments