CORS阿波罗只在前端反应

CORS阿波罗只在前端反应,cors,apollo,react-apollo,Cors,Apollo,React Apollo,我有一个相当愚蠢的问题。我有一个GraphQLAPI,不是我的,在线服务器。我对CORS有一些问题(当我在我的浏览器中执行一些魔术时,效果很好)。像这样的每一个问题都是关于服务器端的,但在这里我不能对服务器做任何事情。那么,有没有可能在没有任何问题的情况下通过前端获取数据?我使用React Apollo stack。我修复了cors问题,将这一行“graphQLServer.use(cors())”添加到我的graphql服务器: import cors from 'cors'; const

我有一个相当愚蠢的问题。我有一个GraphQLAPI,不是我的,在线服务器。我对CORS有一些问题(当我在我的浏览器中执行一些魔术时,效果很好)。像这样的每一个问题都是关于服务器端的,但在这里我不能对服务器做任何事情。那么,有没有可能在没有任何问题的情况下通过前端获取数据?我使用React Apollo stack。

我修复了cors问题,将这一行“graphQLServer.use(cors())”添加到我的graphql服务器:

import cors from 'cors';

const graphQLServer = express();
graphQLServer.use(cors()); // with this line the cors problem is solved
...
graphQLServer.use('/graphql', bodyParser.json(), graphqlExpress({ schema }));
graphQLServer.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));

我修复了cors问题,将此行“graphQLServer.use(cors())”添加到我的graphql服务器:

import cors from 'cors';

const graphQLServer = express();
graphQLServer.use(cors()); // with this line the cors problem is solved
...
graphQLServer.use('/graphql', bodyParser.json(), graphqlExpress({ schema }));
graphQLServer.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));

是的,您可以使用代理。请参见“是”处的答案,您可以使用代理。请参阅第页的答案