0

我正在尝试通过 IP 地址连接到本地开发环境。我收到一个错误,因为 HTTPBatchedNetworkInterface 显示:

_uri: "http://10.0.1.10/graphql"

...当它需要时:

"http://10.0.1.10:3000/graphql"

这是我的服务器端设置代码:

const localHostString = '10.0.1.10';
const METEOR_PORT = 3000;
const GRAPHQL_PORT = 4000;
const server = express();

server.use('*', cors({ origin: `http://${localHostString}:${METEOR_PORT}` }));


server.use('/graphql', bodyParser.json(), graphqlExpress({
    schema,
    context
}));

server.use('/graphiql', graphiqlExpress({
    endpointURL: '/graphql',
    subscriptionsEndpoint: `ws://${localHostString}:${GRAPHQL_PORT}/subscriptions`
}));

// Wrap the Express server
const ws = createServer(server);
ws.listen(GRAPHQL_PORT, () => {
    console.log(`GraphQL Server is now running on http://${localHostString}:${GRAPHQL_PORT}`);
    console.log(`GraphiQL available at http://${localHostString}:${GRAPHQL_PORT}/graphiql`);
    // Set up the WebSocket for handling GraphQL subscriptions
    new SubscriptionServer({
        execute,
        subscribe,
        schema
    }, {
        server: ws,
        path: '/subscriptions',
    });
});

获取端口号的正确方法是什么HTTPBatchedNetworkInterface._uri

提前感谢所有人提供的任何信息。

4

1 回答 1

0

固定的。我的框架是 Meteor,我必须设置ROOT_URL = 10.0.1.10:3000/.

于 2017-09-07T18:51:40.710 回答