AWS API Gateway:使用 302 重定向和 set-cookie 标头

2024-03-28

我使用 AWS API Gateway 进行重定向作为响应。

简单流程: aaa.com ====> API 网关和 Lambda ==[302 重定向]==>bbb.com

跟随时效果很好the blog https://rpgreen.wordpress.com/2016/01/04/how-to-http-redirects-with-api-gateway-and-lambda/。但是,我无法将 cookie 设置为bbb.com.

我按照博客定义了另一个“Set-Cookie”标头。下面列出了我的 Lambda 代码片段。

context.succeed({
    location : "http://192.168.173.193:3030",
    setCookie: "path=/;sessionID=1234;domain=null;"
});

您更新了响应参数吗?

在那篇博文中请注意responseParametersSwagger 示例的部分。

responseParameters:
          method.response.header.Location: "integration.response.body.location"

您需要在映射中添加另一行Set-Cookie范围。就像是:

responseParameters:
          method.response.header.Location: "integration.response.body.location"
          method.response.header.Set-Cookie: "integration.response.body.setCookie"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

AWS API Gateway:使用 302 重定向和 set-cookie 标头 的相关文章

随机推荐