【问题标题】:"Preflight response is not successful" in Apollo Server running on GitHub Codespaces在 GitHub Codespaces 上运行的 Apollo Server 中的“预检响应不成功”
【发布时间】:2021-02-05 19:41:51
【问题描述】:

我在 Github Codespace 中遵循了 Apollo Getting Started 示例。

在启动服务器时,我看到了错误:

{
  "error": "Preflight response is not successful"
}

要复制的示例 repo 在这里:https://github.com/anishkny/codespaces-test

我尝试了cors 的各种选项,但都不起作用:

...
new ApolloServer({ typeDefs, resolvers
  cors: {
    "origin": "*",
    "methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
    "preflightContinue": false,
    "optionsSuccessStatus": 204
  }
});
...

【问题讨论】:

    标签: github apollo-server codespaces


    【解决方案1】:

    我也有同样的问题。事实证明,Playground 没有转发您的 Github 凭据。请注意,如果您在隐身窗口中访问预览 URL,您将被重定向到 Github 登录屏幕。解决方案是更改 Playground 设置,以便在 GraphQL 请求中发送您的凭据。

    1. 点击右上角,点击齿轮图标(设置)
    2. 更改以下内容
    -  "request.credentials": "omit",
    +  "request.credentials": "same-origin",
    

    【讨论】:

    • express-graphql 有类似的东西吗?
    猜你喜欢
    • 2017-03-14
    • 2020-09-05
    • 2022-12-16
    • 2020-11-09
    • 2018-11-19
    • 2023-01-18
    • 2021-09-03
    • 2017-02-02
    • 1970-01-01
    相关资源
    最近更新 更多