StephenGrider / FullstackReactCode

Companion repo to https://www.udemy.com/node-with-react-fullstack-web-development
1.39k stars 1.17k forks source link

Mongoose and Promise Error #55

Open vigilanteRk opened 5 years ago

vigilanteRk commented 5 years ago

Issue 1: [0] (node:3752) UnhandledPromiseRejectionWarning: MongoNetworkError: connection 5 to cluster0-shard-00-02-bioze.mongodb.net:27017 closed [0] at TLSSocket. (E:\Home\server\node_modules\mongodb-core\lib\connection\connection.js:352:9) [0] at Object.onceWrapper (events.js:277:13) [0] at TLSSocket.emit (events.js:189:13) [0] at _handle.close (net.js:597:12) [0] at TCP.done (_tls_wrap.js:388:7) [0] (node:3752) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

Issue 2: [1] When specified, "proxy" in package.json must be a string. [1] Instead, the type of "proxy" was "object". [1] Either remove "proxy" from package.json, or make it a string. [1] npm ERR! code ELIFECYCLE npm ERR! errno 1 [1] npm ERR! client@0.1.0 start: react-scripts start [1] npm ERR! Exit status 1 [1] npm ERR! npm ERR! Failed at the client@0.1.0 start script. [1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above. [1] [1] npm ERR! A complete log of this run can be found in: [1] npm ERR! C:\Users\Samsung user\AppData\Roaming\npm-cache_logs\2019-06-11T06_44_18_943Z-debug.log [1] npm ERR! code ELIFECYCLE npm ERR! errno 1 [1] npm ERR! nodeauth@1.0.0 client: npm run start --prefix client [1] npm ERR! Exit status 1 [1] npm ERR! [1] npm ERR! Failed at the nodeauth@1.0.0 client script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. [1] [1] npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Samsung user\AppData\Roaming\npm-cache_logs\2019-06-11T06_44_18_975Z-debug.log [1] npm run client exited with code 1

I found a post on stackoverflow solution regarding the proxy issue, that says to create a separate setupProxy.js file and apply proxy in below way const proxy = require('http-proxy-middleware'); module.exports = function(app) { app.use(proxy('/auth/google', { target: 'http://localhost:5000' }, "/api/*", { "target": "http://localhost:5000" } )); } and delete the proxy from client/package.json, But this remains a temprory solution, and often the error appears regular

Issue 3: http://localhost:5000/api/current_user the page remains totally blank, no current user is shown

dhuang612 commented 5 years ago

first error white list your ip address from your mongodb cluster. The setting is under security

Yes the setupProxy.js is the accepted solution. there is a text document update inside of the course

vigilanteRk commented 5 years ago

first error white list your ip address from your mongodb cluster. The setting is under security

Yes the setupProxy.js is the accepted solution. there is a text document update inside of the course

Big THANKS: It really worked. But now I'm facing a problem in Heroku deployment, and heroku logs shows chunk of errors, and on heroku server it shows: Cannot GET /

dhuang612 commented 5 years ago

can you post a screenshot of the errors Heroku is showing you?

vigilanteRk commented 5 years ago

can you post a screenshot of the errors Heroku is showing you? Thanks for replly:

image

image

image

dhuang612 commented 5 years ago

So I don't see the repo under your account, is it a private one?

I took a look at the error messages, it looks like something under the options to build out the create-react-app is failing