- 最新
- 投票最多
- 评论最多
I guess mocking API Gateway responses in the AWS Management Console doesn't currently allow directly setting multiple Set-Cookie headers. However, there's a workaround you can use to achieve this by -
1/ Mocking with a Method Response.
2/ Override Response Headers - Use Edit option.
3/ Using Case-Sensitive Header Names (Not Recommended): API Gateway is case-insensitive for request headers, but you can exploit this behavior for response headers . Define multiple Set-Cookie headers with different capitalizations (e.g., Set-Cookie, SET-COOKIE, sEt-Cookie). Each variation will be treated as a separate header, allowing you to set multiple cookies.
"message": "This is a mocked response", "headers": { "Set-Cookie": "cookie1=value1; Expires=Wed, 13 Jun 2024 08:20:00 GMT; Path=/", "SET-COOKIE": "cookie2=value2; Expires=Wed, 13 Jun 2024 08:20:00 GMT; Path=/", "sEt-Cookie": "cookie3=value3; Expires=Wed, 13 Jun 2024 08:20:00 GMT; Path=/" }
OR Using a Single Set-Cookie Header with Multiple Cookies (Recommended):
This approach leverages the standard way cookies are sent in HTTP responses: a single Set-Cookie header with multiple comma-separated cookie definitions.
"Set-Cookie": "cookie1=value1; Expires=Wed, 13 Jun 2024 08:20:00 GMT; Path=/; cookie2=value2; Expires=Wed, 13 Jun 2024 08:20:00 GMT; Path=/; cookie3=value3; Expires=Wed, 13 Jun 2024 08:20:00 GMT; Path=/"
