[英]Set-Cookie header not being sent
I am learning how to handle cookies with node.js and express and I encountered a rather peculiar problem. 我正在学习如何使用node.js来处理cookie并进行表达,但是遇到了一个非常特殊的问题。 My
cookie.js
file looks like this: 我的
cookie.js
文件如下所示:
var router = require('express').Router();
router.get('/cookie/', function(req, res) {
res.append('Set-Cookie', 'foo=bar').cookie('hi', 'hello').status(200).json([]);
});
module.exports = router;
The problem is that the server is not sending the Set-Cookie
header. 问题在于服务器未发送
Set-Cookie
标头。 However, if I modify Set-Cookie
to Set-Cookiie
then the header is sent (albeit not as a cookie). 但是,如果我将
Set-Cookie
修改为Set-Cookiie
则将发送标头(尽管不是作为cookie)。
I also tried to use res.cookie('hi', 'hello')
after requiring and using CookieParser in my server.js
and no cookie header is being sent. 在要求并在
server.js
使用CookieParser之后res.cookie('hi', 'hello')
我还尝试使用res.cookie('hi', 'hello')
,并且未发送任何cookie标头。 Why is this happening? 为什么会这样呢? Are any other packages (I have a few other packages) interfering with my headers?
是否还有其他软件包(我还有一些其他软件包)干扰了我的标头?
Additional Information: I have HTTP running at :80
at HTTPS at :443
(self-signed) and the cookie problem persists in both connections. 其他信息:我在HTTP运行
:80
在HTTPS在:443
(自签名)和cookie的问题仍然存在两个连接。
I believe that with Postman
in order to catch cookies
and sessions
, you have to install a little add-on Postman Interceptor
: 我相信使用
Postman
来捕获cookies
和sessions
,您必须安装一个附加的Postman Interceptor
:
https://chrome.google.com/webstore/detail/postman-interceptor/aicmkgpgakddgnaphhhpliifpcfhicfo https://chrome.google.com/webstore/detail/postman-interceptor/aicmkgpgakddgnaphhhpliifpcfhicfo
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.