小编loc*_*ost的帖子

CORS 不适用于 apollo-server-express

套餐: apollo-server-express

版本: v2.6.0

问题: CORS 设置未生效。

向 Apollo 报告?:是的,第 3058 期

描述:从我们的 React 客户端,我们开始发送apollographql-client-nameapollographql-client-version标头,以在 Apollo Engine 中更好地了解客户端

Access to fetch at 'https://something.com/graphql' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field apollographql-client-name is not allowed by Access-Control-Allow-Headers in preflight response.

我们收到上述CORS错误。我们cors通过传递cors: true. 出于某种原因,这种变化没有任何区别。我们继续收到上述错误。

const server: ApolloServer = new ApolloServer({
...
...
});

const app: Application = express();

server.applyMiddleware({
   app,
   cors: true, …
Run Code Online (Sandbox Code Playgroud)

express apollo graphql

5
推荐指数
1
解决办法
850
查看次数

标签 统计

apollo ×1

express ×1

graphql ×1