menu

JS Everywhere

A community for the JavaScript Everywhere book by Adam Scott, published by O'Reilly.

Channels
Team

Trouble signing in after deploying Notedly

February 7, 2021 at 9:46pm

Trouble signing in after deploying Notedly

February 7, 2021 at 9:46pm
Hi! I deployed the Notedly app on Friday night and I'm unsure why I can't sign back in after signing up. I connected to MongoDB directly and it listed all the new users, so I'm not sure what else to check. Has anyone else had this issue before? Thanks in advance!

February 8, 2021 at 10:11pm
(b-sebe) Welcome! Where exaclty is the error happening? Is the JWT being set in your browser?
  • reply
  • like
The error message I get in the app is from the deployed version. It says "Error signing in!". The message in the web inspector is:
"Failed to load resource: the server responded with a status of 400 (Bad Request). Unhandled Promise Rejection: Error: Network error: Response not succesful:: Received status 400
I'll attach a screenshot of it for further help.
I went back in the book to double-check the mutations, the src/index.js file, the JWT_SECRET variable both in the .env file and in Heroku, my connection in mongoDB to see if there's any misspelling in the connection string, src/signup.js, and signin.js and they seem fine to me.
So it works, locally, I can sign in and I can see the token, too. Please, see the attached screenshot. I also created a new account in the GraphQL Playground, then signed back in and that worked.
Also locally, I constantly get an undefined in the terminal whenever I:
  • sign up and sign in in the Playground
  • click on any of the pages (except for New)
  • Sign Up / Log Out
I'm not sure if these have to do anything with the error I'm getting in the deployed version of the app. I hope any of this helps.
Edited
  • reply
  • like
  • reply
  • like
I forgot to mention that when I sign up in the deployed version, I do see the token generated. So I see it in both versions of the app. It's just that I can't sign back into the deployed app.
  • reply
  • like
Do you have cors enabled in your API? (page 84)
  • reply
  • like

February 11, 2021 at 4:48am
Hi Adam!
Yes, cors was enabled. However, I had a typo in mutations which I corrected. I additionally uploaded the API as well to my Github and switched to Github as my deployment method in Heroku. Everything seems to work perfectly now! Thank you!
Best regards, Boglárka
like-fill
1
  • reply
  • like

February 11, 2021 at 3:55pm
Great!
  • reply
  • like

February 20, 2021 at 6:27am
Tested after adding the refetchQueries option..
Edited
  • reply
  • like

February 20, 2021 at 5:32pm
Glad to hear that you got it working!
  • reply
  • like