Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publicRuntimeConfig is empty during development #8338

Closed
ghost opened this issue Aug 12, 2019 · 3 comments
Closed

publicRuntimeConfig is empty during development #8338

ghost opened this issue Aug 12, 2019 · 3 comments
Labels
please add a complete reproduction The issue lacks information for further investigation

Comments

@ghost
Copy link

ghost commented Aug 12, 2019

Bug report

Using Next.js v9.0.3

Describe the bug

During development, the public runtime config is empty, even though publicRuntimeConfig is set in the config file.
image

However, the config is available when the project is built and running on production.

To Reproduce

  1. Add publicRuntimeConfig in the next.config.js file.
// for example
publicRuntimeConfig: {
 API_URL: 'http://localhost:3001/api'
}
  1. Open browser console and window.__NEXT_DATA__.runtimeConfig as shown in the image above.
  2. It will return empty object {}, even though public runtime config should have API_URL value.

Expected behavior

publicRuntimeConfig should be available both in development and production.

System information

  • Version of Next.js: 9.0.3
@ijjk
Copy link
Member

ijjk commented Aug 13, 2019

Hi, I'm not able to reproduce this on 9.0.3 or the latest canary of Next.js (9.0.4-canary.3). Can you provide a link to a minimal repo with this issue. It's working with the below next.config.js and example page

// next.config.js
module.exports = {
  publicRuntimeConfig: {
    hello: 'world'
  }
}
// pages/index.js
import getConfig from 'next/config'
const { publicRuntimeConfig } = getConfig()

export default () => <p>hello {publicRuntimeConfig.hello}</p>

@ijjk ijjk added the please add a complete reproduction The issue lacks information for further investigation label Aug 13, 2019
@ghost
Copy link
Author

ghost commented Aug 15, 2019

It is working now 😕 .
Thank you for the support.

@balazsorban44
Copy link
Member

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 vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
please add a complete reproduction The issue lacks information for further investigation
Projects
None yet
Development

No branches or pull requests

2 participants