내용으로 건너뛰기

multiple Set-Cookie in API Gateway's mock response

0

How can I mock API Gateway response in the management console and set multiple Set-Cookie values in the response header?

1개 답변
1

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=/"
AWS
답변함 일 년 전
전문가
검토됨 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠