部署到heroku时出现应用程序错误

时间:2020-08-06 19:16:03

标签: node.js heroku

在读取日志时,似乎Google OAuth中存在问题,因为其回调URL为localhost:3000。因此我无法修复它。

这些是heroku日志

2020-08-06T18:58:51.639489+00:00 heroku[web.1]: Starting process with command `npm start`2020-08-06T18:58:55.667318+00:00 app[web.1]: 
2020-08-06T18:58:55.667346+00:00 app[web.1]: > secrets@1.0.0 start /app
2020-08-06T18:58:55.667346+00:00 app[web.1]: > node index.js
2020-08-06T18:58:55.667347+00:00 app[web.1]:
2020-08-06T18:58:56.738632+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-08-06T18:58:56.738668+00:00 app[web.1]: designed for a production environment, as it will leak
2020-08-06T18:58:56.738669+00:00 app[web.1]: memory, and will not scale past a single process.
2020-08-06T18:58:56.785355+00:00 app[web.1]: /app/node_modules/passport-oauth2/lib/strategy.js:86
2020-08-06T18:58:56.785357+00:00 app[web.1]: if (!options.clientID) { throw new TypeError('OAuth2Strategy requires a clientID option'); }
2020-08-06T18:58:56.785358+00:00 app[web.1]: ^
2020-08-06T18:58:56.785359+00:00 app[web.1]: 
2020-08-06T18:58:56.785359+00:00 app[web.1]: TypeError: OAuth2Strategy requires a clientID option
2020-08-06T18:58:56.785360+00:00 app[web.1]: at Strategy.OAuth2Strategy (/app/node_modules/passport-oauth2/lib/strategy.js:86:34)
2020-08-06T18:58:56.785360+00:00 app[web.1]: at new Strategy (/app/node_modules/passport-google-oauth20/lib/strategy.js:52:18)
2020-08-06T18:58:56.785361+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:65:3)  
2020-08-06T18:58:56.785361+00:00 app[web.1]: at Module._compile (module.js:570:32)       
2020-08-06T18:58:56.785362+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2020-08-06T18:58:56.785362+00:00 app[web.1]: at Module.load (module.js:487:32)
2020-08-06T18:58:56.785362+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2020-08-06T18:58:56.785363+00:00 app[web.1]: at Function.Module._load (module.js:438:3)  
2020-08-06T18:58:56.785363+00:00 app[web.1]: at Module.runMain (module.js:604:10)        
2020-08-06T18:58:56.785363+00:00 app[web.1]: at run (bootstrap_node.js:389:7)
2020-08-06T18:58:56.785364+00:00 app[web.1]: at startup (bootstrap_node.js:149:9)        
2020-08-06T18:58:56.785364+00:00 app[web.1]: at bootstrap_node.js:504:3
2020-08-06T18:58:56.796796+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-08-06T18:58:56.797619+00:00 app[web.1]: npm ERR! errno 1
2020-08-06T18:58:56.799572+00:00 app[web.1]: npm ERR! secrets@1.0.0 start: `node index.js`
2020-08-06T18:58:56.799846+00:00 app[web.1]: npm ERR! Exit status 1
2020-08-06T18:58:56.800246+00:00 app[web.1]: npm ERR!
2020-08-06T18:58:56.800511+00:00 app[web.1]: npm ERR! Failed at the secrets@1.0.0 start script.
2020-08-06T18:58:56.800815+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-08-06T18:58:56.816356+00:00 app[web.1]:
2020-08-06T18:58:56.816594+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-08-06T18:58:56.816734+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-08-06T18_58_56_803Z-debug.log
2020-08-06T18:58:56.882429+00:00 heroku[web.1]: Process exited with status 1
2020-08-06T18:58:56.923979+00:00 heroku[web.1]: State changed from starting to crashed   
2020-08-06T18:58:56.930118+00:00 heroku[web.1]: State changed from crashed to starting   
2020-08-06T18:59:00.529632+00:00 heroku[web.1]: Starting process with command `npm start`2020-08-06T18:59:02.858493+00:00 app[web.1]:
2020-08-06T18:59:02.858511+00:00 app[web.1]: > secrets@1.0.0 start /app
2020-08-06T18:59:02.858512+00:00 app[web.1]: > node index.js
2020-08-06T18:59:02.858512+00:00 app[web.1]:
2020-08-06T18:59:03.775308+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-08-06T18:59:03.775334+00:00 app[web.1]: designed for a production environment, as it will leak
2020-08-06T18:59:03.775335+00:00 app[web.1]: memory, and will not scale past a single process.
2020-08-06T18:59:03.811896+00:00 app[web.1]: /app/node_modules/passport-oauth2/lib/strategy.js:86
2020-08-06T18:59:03.811898+00:00 app[web.1]: if (!options.clientID) { throw new TypeError('OAuth2Strategy requires a clientID option'); }
2020-08-06T18:59:03.811898+00:00 app[web.1]: ^
2020-08-06T18:59:03.811899+00:00 app[web.1]:
2020-08-06T18:59:03.811900+00:00 app[web.1]: TypeError: OAuth2Strategy requires a clientID option
2020-08-06T18:59:03.811900+00:00 app[web.1]: at Strategy.OAuth2Strategy (/app/node_modules/passport-oauth2/lib/strategy.js:86:34)
2020-08-06T18:59:03.811900+00:00 app[web.1]: at new Strategy (/app/node_modules/passport-google-oauth20/lib/strategy.js:52:18)
2020-08-06T18:59:03.811901+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:65:3)  
2020-08-06T18:59:03.811901+00:00 app[web.1]: at Module._compile (module.js:570:32)
2020-08-06T18:59:03.811902+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2020-08-06T18:59:03.811902+00:00 app[web.1]: at Module.load (module.js:487:32)
2020-08-06T18:59:03.811902+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2020-08-06T18:59:03.811903+00:00 app[web.1]: at Function.Module._load (module.js:438:3)  
2020-08-06T18:59:03.811907+00:00 app[web.1]: at Module.runMain (module.js:604:10)        
2020-08-06T18:59:03.811907+00:00 app[web.1]: at run (bootstrap_node.js:389:7)
2020-08-06T18:59:03.811908+00:00 app[web.1]: at startup (bootstrap_node.js:149:9)
2020-08-06T18:59:03.811908+00:00 app[web.1]: at bootstrap_node.js:504:3
2020-08-06T18:59:03.822926+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-08-06T18:59:03.823477+00:00 app[web.1]: npm ERR! errno 1
2020-08-06T18:59:03.824880+00:00 app[web.1]: npm ERR! secrets@1.0.0 start: `node index.js`
2020-08-06T18:59:03.825035+00:00 app[web.1]: npm ERR! Exit status 1
2020-08-06T18:59:03.825267+00:00 app[web.1]: npm ERR!
2020-08-06T18:59:03.825456+00:00 app[web.1]: npm ERR! Failed at the secrets@1.0.0 start script.
2020-08-06T18:59:03.825605+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-08-06T18:59:03.832579+00:00 app[web.1]:
2020-08-06T18:59:03.832838+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-08-06T18:59:03.832980+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-08-06T18_59_03_827Z-debug.log
2020-08-06T18:59:03.902827+00:00 heroku[web.1]: Process exited with status 1
2020-08-06T18:59:03.944349+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-06T18:59:07.879891+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secret-anonymous.herokuapp.com request_id=ab5e9261-5105-4b89-bdd0-8f14e9397084 fwd="110.225.83.237" dyno= connect= service= status=503 bytes= protocol=https2020-08-06T18:59:08.552527+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secret-anonymous.herokuapp.com request_id=fa83f921-6670-4182-8f21-7a9401f92e65 fwd="110.225.83.237" dyno= connect= service= status=503 bytes= protocol=https

无法解决问题。但是该应用程序可以在localhost:3000上完美运行

这是github存储库的链接:-https://github.com/Naman-2001/Secrets

1 个答案:

答案 0 :(得分:0)

将所有秘密/敏感密钥(clientID,clientSecret等)放入Heroku配置变量中,以便您可以像process.env.['YOUR SECRET PROPERTY']这样的代码来访问它

详细了解Heroku Configuration and Config Vars