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

better error message when api not reacheable on localhost #647

Closed
wants to merge 1 commit into from

Conversation

xdamman
Copy link
Contributor

@xdamman xdamman commented Aug 3, 2018

@znarf
Copy link
Member

znarf commented Aug 3, 2018

Interesting using next config to forward environment variable to the client side.

Last time we had this need, we used _document.js, maybe your approach is better.

@xdamman
Copy link
Contributor Author

xdamman commented Aug 3, 2018

Tests fail on

 FAIL  src/pages/__tests__/search.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'publicRuntimeConfig' of undefined

      11 | import getConfig from 'next/config'
      12 | 
    > 13 | const { publicRuntimeConfig } = getConfig();
         |         ^
      14 | 
      15 | class ErrorPage extends React.Component {
      16 | 

      at Object.<anonymous> (src/components/ErrorPage.js:13:9)
      at Object.<anonymous> (src/pages/search.js:19:1)
      at Object.<anonymous> (src/pages/__tests__/search.test.js:8:1)

Any idea how to fix that? /cc @HipsterBrown

@xdamman
Copy link
Contributor Author

xdamman commented Aug 3, 2018

@znarf yeah, this comes from their documentation. I believed at the time there wasn't any official way to do it (so it was a hack) https://github.com/zeit/next.js#exposing-configuration-to-the-server--client-side

@znarf
Copy link
Member

znarf commented Aug 7, 2018

@xdamman have a look at that thread vercel/next.js#4024 (comment)

@znarf znarf self-requested a review August 7, 2018 08:25
@znarf
Copy link
Member

znarf commented Aug 7, 2018

screen shot 2018-08-07 at 10 25 29

Let's make sure we're not logging errors to the console while testing. We want a clean console to easily see when something is wrong.

@znarf
Copy link
Member

znarf commented Feb 22, 2019

PR is too old and with too many conflicts.

Feel free to revisit these ideas in a new PR if that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants