问题描述
我在Getting Started中遵循了阿波罗Github Codespace的示例。
启动服务器后,我看到错误:
{
"error": "Preflight response is not successful"
}
要复制的样本回购在这里:https://github.com/anishkny/codespaces-test
我为cors
尝试了各种选项,但没有用:
...
new ApolloServer({ typeDefs,resolvers
cors: {
"origin": "*","methods": "GET,HEAD,PUT,PATCH,POST,DELETE","preflightContinue": false,"optionsSuccessstatus": 204
}
});
...
解决方法
我有同样的问题。事实证明,Playground没有转发您的Github凭据。请注意,如果您在隐身窗口中访问预览URL,则会将您重定向到Github登录屏幕。解决方案是更改Playground设置,以便在GraphQL请求中发送您的凭据。
- 点击右上角,点击齿轮图标(设置)
- 更改以下内容
- "request.credentials": "omit",+ "request.credentials": "same-origin",