简体   繁体   English

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

[英]AWS API Gateway : Use 302 redirect and set-cookie header

I used AWS API Gateway to redirect in response. 我使用AWS API Gateway进行重定向以作为响应。

simple flow : aaa.com ====> API Gateway & Lambda ==[302 redirect]==> bbb.com 简单流程 :aaa.com ====> API Gateway&Lambda == [302 redirect] ==> bbb.com

It worked well when following the blog . 关注博客时效果很好。 However, I couldn't set cookie at bbb.com . 但是,我无法在bbb.com上设置cookie。

I followed the blog and defined another “Set-Cookie” header. 我跟着博客,定义了另一个“Set-Cookie”标题。 My Lambda code snippet listed below. 我的Lambda代码片段如下所示。

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

Did you update your Response Parameters? 您是否更新了响应参数?

In that blog post notice the responseParameters section of the Swagger Example. 在该博客文章中,请注意Swagger示例的responseParameters部分。

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

You need to add another line to that mapping the Set-Cookie parameter. 您需要在Set-Cookie参数的映射中添加另一行。 Something like: 就像是:

responseParameters:
          method.response.header.Location: "integration.response.body.location"
          method.response.header.Set-Cookie: "integration.response.body.setCookie"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM