【发布时间】: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