Marcel-G / keystone-graphql-next

Full stack node with Next.js frontend & KeystoneJs backend over GraphQL.
17 stars 6 forks source link

Apollo Errors, HELP! #1

Closed eltel closed 7 years ago

eltel commented 7 years ago

So, I got past some initial errors but can't seem to resolve these Apollo errors. Getting the following:

Error: Network error: request to http://localhost:3001/api failed, reason: connect ECONNREFUSED 127.0.0.1:3001 at ApolloError.Error (native) at new ApolloError (C:\Users\Terry\Documents\GitHub\KeystoneJs-GraphQL-NextJs\client\node_modules\apollo-client\apollo.umd.js:1959:28) at C:\Users\Terry\Documents\GitHub\KeystoneJs-GraphQL-NextJs\client\node_modules\apollo-client\apollo.umd.js:2827:41 at C:\Users\Terry\Documents\GitHub\KeystoneJs-GraphQL-NextJs\client\node_modules\apollo-client\apollo.umd.js:3262:25 at Array.forEach (native) at C:\Users\Terry\Documents\GitHub\KeystoneJs-GraphQL-NextJs\client\node_modules\apollo-client\apollo.umd.js:3259:27 at Array.forEach (native) at QueryManager.broadcastQueries (C:\Users\Terry\Documents\GitHub\KeystoneJs-GraphQL-NextJs\client\node_modules\apollo-client\apollo.umd.js:3256:42) at QueryManager.broadcastNewStore (C:\Users\Terry\Documents\GitHub\KeystoneJs-GraphQL-NextJs\client\node_modules\apollo-client\apollo.umd.js:2631:14) at C:\Users\Terry\Documents\GitHub\KeystoneJs-GraphQL-NextJs\client\node_modules\apollo-client\apollo.umd.js:3314:44

Any help greatly appreciated - I'd love to start working with this! :)

eltel commented 7 years ago

Also getting build errors on yarn build/yarn run build.

npm ERR! Tell the author that this fails on your system: [1] npm ERR! NODE_ENV=production next build

edit: fixed build errors by removing:"NODE_ENV=production" from 'build' in package.json(client)

Though still receiving the above Apollo errors.

Have a feeling it (the Apollo/ECONNREFUSED 127.0.0.1:3001 error) may be related to MongoDB? I've confirmed it's running on my system. Cant' open either keystone or client side :(

Marcel-G commented 7 years ago

@eltel that request to http://localhost:3001/api failed error means that nextJs cannot connect to the api server. It has probably failed to start. Check your console for [nodemon] app crashed - waiting for file changes before starting... Before that there should be more info on why the crash happened. A mongo error could be: { MongoError: failed to connect to server [localhost:27017] on first connect ... In this case make sure mongo is running. However it is likely a keystone error like: Please provide a 'cookie secret' value for session encryption. This means you need to create a .env file from the .env.example in /api. Make sure to fill in the values, a random secret string will do.

eltel commented 7 years ago

Hi thanks for getting back to me.

Please, forgive my ignorance but I'm still a bit of a noob with mongoDB - I've a feeling I've misconfigured by leaving the MONGO_URI as : MONGO_URI=mongodb://localhost/Keystone as the secret is already configured - is that right??

Here's the error message which says the 'secret' needs to be set at various location/files? Am I reading this correctly?? Here's the error:

Error: secret should be set [0] [1] at module.exports (C:\Users\Terry\Documents\github\KeystoneJs-GraphQL-NextJs\api\node_modules\express-jwt\lib\index.js:20:42) [0] [1] at module.exports (C:\Users\Terry\Documents\github\KeystoneJs-GraphQL-NextJs\api\routes.dist.js:652:19) [0] [1] at createApp (C:\Users\Terry\Documents\github\KeystoneJs-GraphQL-NextJs\api\node_modules\keystone\server\createApp.js:140:4) [0] [1] at Keystone.initExpressApp (C:\Users\Terry\Documents\github\KeystoneJs-GraphQL-NextJs\api\node_modules\keystone\lib\core\initExpressApp.js:9:47) [0] [1] at Keystone.start (C:\Users\Terry\Documents\github\KeystoneJs-GraphQL-NextJs\api\node_modules\keystone\lib\core\start.js:47:7) [0] [1] at Object. (C:\Users\Terry\Documents\github\KeystoneJs-GraphQL-NextJs\api\keystone.js:58:10) [0] [1] at Module._compile (module.js:570:32) [0] [1] at Object.Module._extensions..js (module.js:579:10) [0] [1] at Module.load (module.js:487:32) [0] [1] at tryModuleLoad (module.js:446:12) [0] [1] at Function.Module._load (module.js:438:3) [0] [1] at Module.runMain (module.js:604:10) [0] [1] at run (bootstrap_node.js:394:7) [0] [1] at startup (bootstrap_node.js:149:9) [0] [1] at bootstrap_node.js:509:3 [0] [1] [nodemon] app crashed - waiting for file changes before starting...

Many thanks!! :)

EDIT: I tried adding the secret with or without quotes still same error message - I'm sure I'm missing something obvious here.

Marcel-G commented 7 years ago

@eltel what does your .env file look like? Make sure you fill in the secret tokens.

COOKIE_SECRET=somethingsupersecret

JWT_SALT=somethingsupersecret

MONGO_URI=mongodb://localhost/keystone
eltel commented 7 years ago

OK, so - JWT_SALT was be the problem - I had no idea it needed to be filled beforehand :(

Thanks so much for your help - digging in now!! :) 👍

eltel commented 7 years ago

Hi Marcel!!

It's me again :) The Mailgun integration doesn't seem to work as implemented by the original Keystone, it's asking for the info to be added to the .env file as well - do you have any ideas on how to go about this - do you have an alternative? I've lost a good couple of hours on google looking into this.

Once again, many thanks for any input you may have.

Marcel-G commented 7 years ago

@eltel I have not investigated mailgun and mandrill support here but these should work out of the box with Keystone. Head over to Keystone docs for more on that.

Sent from my OnePlus ONEPLUS A5000 using FastHub

eltel commented 7 years ago

Thanks man, been on it for a good few hours - waiting for Mailgun support now as the instructions seem to be outdated (console requesting ,env configuration not mentioned in keystone setup instructions in any way). I'll find a workaround one way or another. Great work btw!

On Wed, 26 Jul 2017, 00:10 Marcel-G, notifications@github.com wrote:

@eltel https://github.com/eltel I have not investigated mailgun and mandrill support here but these should work out of the box with Keystone. Head over to Keystone docs for more on that.

Sent from my OnePlus ONEPLUS A5000 using FastHub https://play.google.com/store/apps/details?id=com.fastaccess.github

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Marcel-G/KeystoneJs-GraphQL-NextJs/issues/1#issuecomment-317935055, or mute the thread https://github.com/notifications/unsubscribe-auth/AEcKLBpoFrvXsmzUS0yx-nrs4QslspuJks5sRq4dgaJpZM4OSKDO .