饼干未设置在Apollo Studio的集成游乐场中,该操作室连接到本地开发环境,域错误

发布于 2025-01-25 10:57:38 字数 925 浏览 4 评论 0原文

我有一个带有打字稿应用程序的节点,该节点由以下组件构建:

    "apollo-server-core": "^3.6.7",
    "apollo-server-express": "^3.6.7",
    "argon2": "^0.28.5",
    "class-validator": "^0.13.2",
    "connect-redis": "^6.1.3",
    "cors": "^2.8.5",
    "dataloader": "^2.1.0",
    "dotenv": "^16.0.0",
    "dotenv-safe": "^8.2.0",
    "express": "^4.17.3",
    "express-session": "^1.17.2",
    "graphql": "^15.8.0",
    "ioredis": "^5.0.4",
    "nodemailer": "^6.7.3",
    "pg": "^8.7.3",
    "prop-types": "^15.8.1",
    "type-graphql": "^1.1.1",
    "typeorm": "^0.3.6",
    "uuid": "^8.3.2"

在此应用程序中,我使用cookie作为身份验证令牌的模式。现在,当我从前端登录(Localhost:3000)时,将获取cookie并正确设置,而没有浏览器中没有任何错误。

之后,当我在Apollo Studio上运行相同的突变(已更换了旧的GraphQl Playground)cookie,但由于以下域错误

消息

而 因为它的域属性无效。

没有被设置-cookie标头被阻止, img src =“ https://i.sstatic.net/9cthv.png” alt =“在此处输入图像说明”>

I've a node with typescript app which is build with the following components:

    "apollo-server-core": "^3.6.7",
    "apollo-server-express": "^3.6.7",
    "argon2": "^0.28.5",
    "class-validator": "^0.13.2",
    "connect-redis": "^6.1.3",
    "cors": "^2.8.5",
    "dataloader": "^2.1.0",
    "dotenv": "^16.0.0",
    "dotenv-safe": "^8.2.0",
    "express": "^4.17.3",
    "express-session": "^1.17.2",
    "graphql": "^15.8.0",
    "ioredis": "^5.0.4",
    "nodemailer": "^6.7.3",
    "pg": "^8.7.3",
    "prop-types": "^15.8.1",
    "type-graphql": "^1.1.1",
    "typeorm": "^0.3.6",
    "uuid": "^8.3.2"

In this app I'm using cookies as mode of authentication token. Now when I login from my frontend (localhost:3000), the cookie is fetched and set correctly without any errors in the browser.

After that, when I'm running the same mutation on Apollo studio (which has replaced the old graphQL playground) cookies are fetched but are not getting set because of following domain error

Error Message:

This attempt to set a cookie via Set-Cookie header was blocked because its Domain attribute was invalid with regards to the current host url.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抱着落日 2025-02-01 10:57:38
  1. 首先,我们需要为工作室启用保存凭据并保存它。

  2. 更新Express Cookie设置代码以允许以下标题

Access-Control-Allow-Origin: https://studio.apollographql.com
Access-Control-Allow-Credentials: true
  1. 添加X-Forwarded Proto带有https作为突变的值,该值将请求并设置Cookie

随着这些步骤的问题,应解决无效域的问题

  1. First we need to enable save credentials for studio and save it.
    enter image description here

  2. Update the express cookie setup code to allow following headers

Access-Control-Allow-Origin: https://studio.apollographql.com
Access-Control-Allow-Credentials: true
  1. Add the x-forwarded-proto header with https as value for your mutation which will request and set the cookie
    enter image description here

With these steps issue of invalid domain should get resolved

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文