【问题标题】:Requests to express-graphql fails with "message": "Authentication failed." after server is deployed to Heroku对 express-graphql 的请求失败并显示“消息”:“身份验证失败。”服务器部署到 Heroku 后
【发布时间】:2023-03-10 21:05:01
【问题描述】:

我认为这与标题有关,但我不太确定。 在本地运行 NodeJs 应用程序没有任何问题,并且请求正常运行。

我的 NodeJs 起点如下所示:

const express = require('express');
const cors = require('cors');
const graphqlHTTP = require('express-graphql');

const schema = require('./graphql/schema');

const { PORT, listenCallback } = require('./config/server.config');

const app = express();

app.use(cors());

app.use('/graphql', graphqlHTTP({
    schema,
    graphiql: true,
}));

app.listen(PORT, listenCallback);

来自服务器的响应总是如下所示:

{
  "errors": [
    {
      "message": "Authentication failed.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "profile"
      ]
    }
  ],
  "data": {
    "profile": null
  }
}

我应该在我的配置中设置一些额外的东西吗? 这只有在服务器成功上传到 Heroku 后才会发生。

【问题讨论】:

    标签: node.js express graphql


    【解决方案1】:

    看起来我在 Heroku 中连接到 MongoDB 时遇到问题,并且与之前认为的 GraphQl 没有任何关系。

    【讨论】:

      猜你喜欢
      • 2021-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-13
      • 1970-01-01
      • 2021-12-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多