【问题标题】:How to set httponly cookie with kong gateway如何使用 kong 网关设置 httponly cookie
【发布时间】:2022-07-27 09:06:54
【问题描述】:

所以我有一个后端,其中包含一个端点,用于在管理员登录时设置一个 httponly cookie。这是代码:

        // Set the cookie
        response.cookie("refreshToken", refreshToken, {
            maxAge: 3.154e10,
            httpOnly: true,
        });

        response.send(this.UtilsInstance.sendOutput(message.Success, {
            accessToken : accessToken,
            username : removePasswordFromAdminData.username,
            role : removePasswordFromAdminData.role
        }));

这就是前端的方式:

await axios
.post('http://my_url/auth/v1/admin/login/',
    {
        'username': username.value,
        'password': password.value
    }, {
        withCredentials: true
    }
);

还有 kong.yaml

plugins:
   - name: cors
   route: auth-routes
   config:
      origins:
      - http://localhost:3000
      methods:
      - GET
      - POST
      - PUT
      - DELETE
      headers:
      - Accept
      - Accept-Version
      - Authorization
      - Content-Length
      - Content-MD5
      - Content-Type
      - Date
      - X-Auth-Token
      exposed_headers:
      - X-Auth-Token
      credentials: true
      max_age: 3600
      preflight_continue: false

代码运行顺利,没有任何错误(我得到了响应),但是在调用 API 后我在开发工具上看不到 httponly cookie。我在这里错过了什么?

【问题讨论】:

  • 只是想添加一些注释,当我在没有网关的情况下运行代码时,程序按预期运行。所以肯定某处的kong配置有问题......
  • 你能检查kong收到的查询和kong发送到浏览器的查询吗?

标签: node.js microservices kong


【解决方案1】:

我也有同样的问题。如果我发现了这方面的信息,我会告诉你的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-30
    • 2012-10-20
    • 2010-09-07
    • 1970-01-01
    • 2020-03-19
    • 2011-04-01
    相关资源
    最近更新 更多