向源发送请求时出错。 Apollo Engine 如何配置apollo engine origins?

Error sending request to origin. Apollo Engine how to configure apollo engine origins?

我正在尝试向我的 /graphiql IDE 发出请求,但我收到关于我的来源的超时错误。

ERRO[0515] Error sending request to origin. This means that the origin GraphQL server did not respond to theproxied request in time. To resolve this, verify the Origin specification in the Engine configuration matches the corresponding GraphQL server. If the error was a timeout error, consider increasing origin.requestTimeout in the Engine configuration. error="Post http://127.0.0.1:51301/graphql: net/http: request canceled (Client.Timeout exceeded while awaiting headers)" url="http://127.0.0.1:51301/graphql"

请记住 url (http://127.0.0.1:51301/graphql) 端口在每个 运行 上都会发生变化,所以这让我相信阿波罗引擎一定是 url代理正在运行,因为我的服务器上没有任何东西会像那样更改端口号。

我的apollo引擎配置是这样的

import { ApolloEngine } from "apollo-engine";
import { ENGINE_API_KEY, PORT } from "../config/keys";
import { INFO } from "./utils/logging";

import app from './app';

const LOG_START = () => INFO(`Listening! at port: ${PORT}`);

/*
  setup Apollo Engine
*/
const engine = new ApolloEngine({
  apiKey: process.env.ENGINE_API_KEY || ENGINE_API_KEY,
});

/*
  Config for Apollo Engine to serve
*/
const ENGINE_SERVE = {
  port: PORT,
  graphqlPaths: ["/graphql"],
  expressApp: app,
  launcherOptions: {
    startupTimeout: 3000
  }
};

/*
  Entry point for application starts server
*/
engine.listen(ENGINE_SERVE, LOG_START);

我的端口号是:8080

我的 Apollo 服务器是这样设置的

import cors from "cors";
import morgan from "morgan";
import express from "express";
import bodyParser from "body-parser";
import compression from "compression";
import { graphqlExpress, graphiqlExpress } from "apollo-server-express";

import connectDb from "./connectors/mongo-connector";
import schema from "./schemas/schema";

/*
  Create express application
*/
const app = express();

/*
  Configure graphql server
*/
const GRAPH_EXPRESS = graphqlExpress({
  schema,
  tracing: true,
  context: { db: async () => await connectDb() }
});

/*
  Configure Graphql IDE for testing
*/
const GRAPH_IDE = graphiqlExpress({ endpointURL: "/graphql" });

/*
  Middleware and route handlers
*/
app.use(cors());
app.use(morgan("dev"));
app.use(compression());
app.use("/graphql", bodyParser.json(), GRAPH_EXPRESS);
app.use("/graphiql", GRAPH_IDE);

export default app;

我不明白为什么我的请求没有被返回我试过了

增加我的源超时并在我的引擎配置中明确设置我的源。但是我无法设置 URL 错误提示,因为端口每次都在变化,所以我有点不知所措,我们将不胜感激。

"origins": [
    {
      "http": {
        "requestTimeout": "60s",
        "url": "http://localhost:8080/graphql",
        "overrideRequestHeaders": {
          "Host": "localhost"
        }
      }
    }
  ]

问题是我的 mongo 连接器没有触发,因为没有 mongo 连接我的端点超时,我误解了错误的含义。

 const GRAPH_EXPRESS = graphqlExpress({
      schema,
      tracing: true,
      context: { db: connectDb() }
 });