我正在使用Golang http
库来设置jwt
cookie并在成功登录后将其返回给客户端,就像这样:
cookie := &http.Cookie{
Name: "jwt",
Value: "XXXXXXXX",
Domain: "irisvr-dev.com",
}
http.SetCookie(p_w, cookie)
我首先从https://irisvr.com
向https://api.irisvr.com
发送请求:
authority: api.irisvr-dev.com
method: POST
path: /v3/auth/user/login
scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9,ko-KR;q=0.8,ko;q=0.7
content-length: 57
content-type: application/json
origin: https://irisvr-dev.com
referer: https://irisvr-dev.com/login
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
服务器将按预期响应:
access-control-allow-credentials: true
access-control-allow-headers: X-Requested-With,Content-Type,Authorization,Iris-User-Id
access-control-allow-methods: POST, GET, OPTIONS, PUT, DELETE
access-control-allow-origin: *
alt-svc: clear
content-length: 380
content-type: application/json
date: Fri, 09 Nov 2018 15:27:12 GMT
set-cookie: jwt=XXXXXXXX; Domain=irisvr-dev.com // <-------- here
status: 200
via: kong/0.14.0, 1.1 google
x-kong-proxy-latency: 1
x-kong-upstream-latency: 50
但是,在开发工具中检查Document.cookie
和/或展开Cookies选项卡不会显示正在设置的jwt。我肯定启用了cookie,因为您可以看到其他一些第三方插件成功设置了它们:
我在这里想念什么?