"内部服务器错误"在Heroku

时间:2018-01-14 08:24:07

标签: heroku oauth passport.js

在发布之前,我第一次找不到答案。我一直在为Heroku的React应用程序部署一个仅API的后端。当Google Passport策略callbackURL设置为proxy: true的相对路径时,它会按照预期完美地与Google进行身份验证:

  new GoogleStrategy(
    {
      clientID: process.env.GOOGLE_OAUTH_CLIENT_ID,
      clientSecret: process.env.GOOGLE_OAUTH_CLIENT_SECRET,
      callbackURL: '/auth/google/callback',
      proxy: true
    }, async () => awaitHandlerFn)

但是当我尝试使用绝对路径作为callbackURL时,它会响应"内部服务器错误" (有或没有proxy: true):

callbackURL: 'https://herokudomain.herokuapp.com/auth/google/callback'

注意:我实际上是从另一个process.env.VARIABLE中分配这个绝对的callbackURL

我确保所有相关的"授权的JavaScript起源"和#34;授权重定向URI"保存在我的Google凭据中=> OAuth 2.0客户端ID,(来源:https://herokudomain.herokuapp.com&& URI:https://herokudomain.herokuapp.com/auth/google/callback

以下是Heroku

中记录的错误消息
2018-01-14T07:48:46.637525+00:00 app[web.1]: ::ffff:10.97.231.53 - - [14/Jan/    2018:07:48:46 +0000] "GET /auth/google HTTP/1.1" 500 148 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
2018-01-14T07:48:46.642273+00:00 app[web.1]: Error: Unknown authentication strategy "google"
2018-01-14T07:48:46.642276+00:00 app[web.1]:     at attempt (/app/node_modules/passport/lib/middleware/authenticate.js:186:37)
2018-01-14T07:48:46.642277+00:00 app[web.1]:     at authenticate (/app/node_modules/passport/lib/middleware/authenticate.js:362:7)
2018-01-14T07:48:46.642278+00:00 app[web.1]:     at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2018-01-14T07:48:46.642280+00:00 app[web.1]:     at next (/app/node_modules/express/lib/router/route.js:137:13)
2018-01-14T07:48:46.642281+00:00 app[web.1]:     at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
2018-01-14T07:48:46.642282+00:00 app[web.1]:     at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2018-01-14T07:48:46.642283+00:00 app[web.1]:     at /app/node_modules/express/lib/router/index.js:281:22
2018-01-14T07:48:46.642284+00:00 app[web.1]:     at Function.process_params (/app/node_modules/express/lib/router/index.js:335:12)
2018-01-14T07:48:46.642285+00:00 app[web.1]:     at next (/app/node_modules/express/lib/router/index.js:275:10)
2018-01-14T07:48:46.642286+00:00 app[web.1]:     at Function.handle (/app/node_modules/express/lib/router/index.js:174:3)
2018-01-14T07:48:46.642287+00:00 app[web.1]:     at router (/app/node_modules/express/lib/router/index.js:47:12)
2018-01-14T07:48:46.642288+00:00 app[web.1]:     at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2018-01-14T07:48:46.642289+00:00 app[web.1]:     at trim_prefix (/app/node_modules/express/lib/router/index.js:317:13)
2018-01-14T07:48:46.642290+00:00 app[web.1]:     at /app/node_modules/express/lib/router/index.js:284:7
2018-01-14T07:48:46.642291+00:00 app[web.1]:     at Function.process_params (/app/node_modules/express/lib/router/index.js:335:12)
2018-01-14T07:48:46.642292+00:00 app[web.1]:     at next (/app/node_modules/express/lib/router/index.js:275:10)
2018-01-14T07:48:47.118813+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=herokudomain.herokuapp.com request_id=fcd2da6e-c14e-46e2-b51d-dfe377ecddaa fwd="137.59.252.191" dyno=web.1 connect=1ms service=2ms status=304 bytes=181 protocol=https
2018-01-14T07:48:43.588370+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=herokudomain.herokuapp.com request_id=3293e3fb-050f-4489-be51-d541243ef0a5 fwd="137.59.252.191" dyno=web.1 connect=1ms service=5ms status=304 bytes=181 protocol=https
2018-01-14T07:48:46.638620+00:00 heroku[router]: at=info method=GET path="/auth/google" host=herokudomain.herokuapp.com request_id=faff85e5-a932-4c8c-8bb5-096378288ad9 fwd="137.59.252.191" dyno=web.1 connect=1ms service=6ms status=500 bytes=436 protocol=https

这可能实际上是对Heroku部署的OAuth或Passport的限制,但无论哪种方式,我希望有人可以确认错误并解释原因。谢谢!

0 个答案:

没有答案
相关问题