Only the last Set-Cookie is returned for responses served through a route rewrite to a linked Functions backend
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
调研方向
Start with the linked Node.js Functions backend and staticwebapp.config.json, comparing direct /api/login requests with requests rewritten to /api/ssr. Reproduce the deployed behavior against the SWA CLI emulator and trace how rewritten responses parse and forward Set-Cookie headers. Done means both cookies reach the client through the rewrite, matching direct-route behavior.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
A linked Azure Functions backend returns two Set-Cookie headers. Requests to the function route (/api/login) receive both. Requests served through a route rewrite ("route": "/*", "rewrite": "/api/ssr") receive only the last one. Each cookie on its own works, and both use the same domain and attributes. The SWA CLI emulator returns both cookies on every route.
To Reproduce
The function (Node.js, @azure/functions v4 with app.setup({ enableHttpStream: true })) returns these cookies through HttpResponse.cookies:
oauth=…; Domain=<host>; Path=/; HttpOnly; Secure; SameSite=Lax
oct_return_to=%2Fdocs; Max-Age=600; Domain=<host>; Path=/api/login; HttpOnly; Secure; SameSite=Lax
staticwebapp.config.json (relevant part):
{
"routes": [
{ "route": "/api/login", "methods": ["GET", "POST"] },
{ "route": "/*", "rewrite": "/api/ssr" }
]
}
| Request | Deployed SWA | func start + swa start (CLI 2.0.10) |
|---|---|---|
POST /api/login?returnTo=%2Fdocs |
2 Set-Cookie |
2 Set-Cookie |
POST /auth/login?redirectUrl=%2Fdocs (rewritten to /api/ssr) |
1 Set-Cookie (last one only) |
2 Set-Cookie |
POST /auth/login.data?redirectUrl=%2Fdocs (rewritten to /api/ssr) |
1 Set-Cookie (last one only) |
2 Set-Cookie |
The same build artifact was used in both columns. Running the function app on its own (func start, requests sent straight to /api/ssr) also returns both cookies. The behaviour is the same with and without a CDN in front of the static web app.
Expected behavior
All Set-Cookie headers returned by the linked backend are forwarded to the client, regardless of whether the request matched a rewrite rule.
Additional context
- Every
Set-Cookiethat reaches the client has lowercased attributes (max-age=600; domain=…; path=…), so SWA appears to parse and re-serialize cookies; the drop seems to happen in that step. - Related: #278 (same symptom, fixed in 2021 for direct API routes), #760, #1214.
- 主要语言
- 没有语言数据
- 星标
- 347
- 派生
- 68
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Azure/static-web-apps 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
Azure/static-web-apps#1764 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 25/100
Azure/static-web-apps#1827 ·
-
难度 4/5 3-5 天 新手友好度 35/100
Azure/static-web-apps#1826 · 5 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 42/100
Azure/static-web-apps#1825 ·
-
难度 4/5 3-5 天 新手友好度 18/100
Azure/static-web-apps#1824 ·
查看 Azure/static-web-apps 的全部 Issue
相似的 Issue
-
component/media domain/discovery
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
roadmap/v1.2.0 type/bug
难度 2/5 1-3 小时 新手友好度 68/100
databrickslabs/ontos#1773 ·
维护者通常 2 天内回复
-
bug good first issue help wanted up-for-grabs
难度 2/5 1-3 小时 新手友好度 78/100
ClickHouse/loom#2075 ·
维护者通常 1 天内回复
-
[Bug]: The trt-decoder extra installs TensorRT 11, which the trt_decoder plugin cannot load可能已有人在做 @fedonman 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100