API Server Error & Authentication Error

I am getting a few errors that I need some help with when I follow the starter docs.

The first error crops up when I get past the “Deploy” step of the tutorial and I navigate to http://localhost:8910/admin/posts

The RedwoodJS API server is not available or is currently reloading. Please refresh.

When I refresh the error does not go away…

Here is the full error that pops up in my terminal

Summary
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/graphql to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/graphql to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/graphql to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/graphql to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/graphql to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

I read through this issue which had the same error, but I am not tracking on how they fixed it


The second error is when I try to display the signed in users email. Following the tutorial here I get this error

My temp work around was to use currentUser.id and that made the error go away but then the next time I spun up a local environment I got the same error but instead of (reading 'email') it was (reading 'id')… I remember having this issue about six months or so ago but I am blanking on how I solved it. I think it had something to do with my Yarn version (which I am running 1.22.17 btw).

Hmm this seems like react is trying to render before you have the current user. One thing you could try is currentUser?.email and see if that helps with the rendering issue. Although the redwood auth provider should prevent the page from showing before it receives the currentUser

I gave currentUser?.email a try and it did not clear the error…

Hmm also its interesting that it’s highlighting the tag is your home route expecting a parameter of email?

I ran yarn rw test and got three failures. The one that may pertain to my first issue The RedwoodJS API server is not available or is currently reloading. Please refresh. is throwing this error:

Full Error
 FAIL   api  api/src/services/contacts/contacts.test.js (9.325 s)
  ● contacts › creates a contact

    EmailValidationError: Email must be formatted like an email address

      13 |
      14 | export const createContact = ({ input }) => {
    > 15 |   validate(input.email, 'email', { email: true })
         |   ^
      16 |   return db.contact.create({
      17 |     data: input,
      18 |   })

      at validationError (node_modules/@redwoodjs/api/dist/validations/validations.js:288:9)
      at Object.email (node_modules/@redwoodjs/api/dist/validations/validations.js:84:7)
      at validate (node_modules/@redwoodjs/api/dist/validations/validations.js:311:26)
      at createContact (api/src/services/contacts/contacts.js:15:3)
      at api/src/services/contacts/contacts.test.js:29:26
      at Object.<anonymous> (node_modules/@redwoodjs/testing/config/jest/api/jest.setup.js:163:22)

It seems that validate is not functioning properly and that is on the API side of Redwood… :thinking:

is your home route expecting a parameter of email?

How would I check that?

On second thought I think those test errors are to be expected (as I proceeded from the Intermission portion using my own code built from Chapters 1-4…). From the starter docs:

If you continued with your own repo from chapters 1-4, you may see some failures here: we made a lot of changes to the pages, components and cells we generated, but didn’t update the tests to reflect the changes we made.

Yeah that error seems to be saying that input.email does not looks like test@email.com