node.js - Cookie 在 HttpHeaders 中可用,但在应用程序中不可用
问题描述
我的 Express 会话是 -
secret: 'secret',
resave: false,
saveUninitialized: false,
cookie:{
maxAge:600000,
httpOnly:false,
secure:false,
SameSite:"None"
}
}))
CORS 详细信息是 -
// CORS enabled
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "http://localhost:4200, http://127.0.0.1:4200"); // update to match the domain you will make the request from
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Allow-Credentials", true);
next();
});
app.use(cors({
origin:['http://localhost:4200','http://127.0.0.1:4200'],
credentials:true
}))
我对角度的要求是 -
{
observe:'body',
withCredentials:true,
headers:new HttpHeaders().append('Content-Type','application/json')
}
我不确定为什么 cookie 在标头的 set-cookie 下可用,但在 Application.cookie 中不可用。正在从 localhost:4200 向 localhost:3000 发出请求。
解决方案
推荐阅读
- javascript - 表格行/单元格与表格高度相同
- swift - Swift - 未显示特定日期的通知
- excel - 如何创建与两个复选框交互的单元格链接
- android - edgar.yodgorbek.yangiliklar.sportactivities.BBCSportFragment.onCreateView(BBCSportFragment.kt:62) 处的表达式“recyclerView”不得为空
- asp.net - 应用程序和基础层之间的循环引用.Net Core
- android - 处理密钥库文件?
- selenium - 试图让 altair 在 PythonAnywhere 平台中保存 .png 或 .svg
- python - Pandas Timestamp 轮换 30 秒不一致
- python - 如何为嵌套字典返回类型添加 python 文档字符串
- python - 为什么此代码在全局变量中设置 True 和 False?