firebase / firebase/firebase-functions
res.cookie option with sameSite 'none' throws TypeError: option sameSite is invalid at Object.serialize
- 主要语言
- TypeScript
- 星标
- 1.1k
- 派生
- 232
- 平均合并
- 20 小时 46 分钟
- 30 天内合并 PR
- 15
描述
### Related issues
I found the issue for Express framework
https://github.com/expressjs/express/issues/3958
and looks it was fixed there.
### [REQUIRED] Version info
node: v10.16.3
**firebase-tools:**
8.0.0.
### [REQUIRED] Test case
export const sameSiteCookie = functions.https.onRequest((req, res) => {
cors(req, res, () => {
const expiresIn = 60 * 60 * 24 * 5 * 1000;
const options: any = {
maxAge: expiresIn,
httpOnly: true,
secure: true,
sameSite: 'none',
};
res.cookie('testCKI', 'value123', options);
res.end(JSON.stringify({
data: {
status: 'success'
}
}));
});
});
### [REQUIRED] Steps to reproduce
calling the cloud function above
### [REQUIRED] Expected behavior
set cookie value to SameSite=Never
### [REQUIRED] Actual behavior
TypeError: option sameSite is invalid at Object.serialize (/worker/node_modules/cookie/index.js:174:15) at ServerResponse.res.cookie (/worker/node_modules/express/lib/response.js:853:36) at cors (/srv/lib/index.js:106:13) at cors (/srv/node_modules/cors/lib/index.js:188:7) at /srv/node_modules/cors/lib/index.js:224:17 at originCallback (/srv/node_modules/cors/lib/index.js:214:15) at /srv/node_modules/cors/lib/index.js:219:13 at optionsCallback (/srv/node_modules/cors/lib/index.js:199:9) at corsMiddleware (/srv/node_modules/cors/lib/index.js:204:7) at exports.sessionLogin.functions.https.onRequest (/srv/lib/index.js:98:5)
### Were you able to successfully deploy your functions?
no error messages seen
贡献指南
调研方向
从提供的 TypeScript 测试用例以及 node_modules/cookie/index.js:174 和 express/lib/response.js:853 处的堆栈跟踪开始;将依赖项的行为与相关的 Express issue #3958 进行比较。使用 firebase-tools 8.0.0 重现,并确认 res.cookie 接受 sameSite: 'none',且在没有 TypeError 的情况下发出预期的 cookie。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- express, firebase, node.js, typescript
- 领域
- api, backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100