首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用对流层为CloudFront发行版设置cookie?

如何使用对流层为CloudFront发行版设置cookie?
EN

Stack Overflow用户
提问于 2019-07-10 22:18:39
回答 1查看 125关注 0票数 0

使用troposhphere,我正在尝试创建CloudFront发行版。

代码语言:javascript
复制
CacheBehaviors = [
                CacheBehavior(
                    TargetOriginId = Join("", ["cloudfront-", Ref("ParamOriginName")]),
                    PathPattern = '/en/Login/*',
                    AllowedMethods = ["GET", "HEAD", "OPTIONS", "PUT", "POST","PATCH"],
                    ForwardedValues = ForwardedValues(
                        QueryString = True,
                        Headers = ["user-agent",
                                "Host",
                                "CloudFront-Forwarded-Proto", 
                                "CloudFront-Is-Desktop-Viewer", 
                                "CloudFront-Is-Mobile-Viewer",
                                "CloudFront-Is-SmartTV-Viewer",
                                "CloudFront-Is-Tablet-Viewer",
                                "CloudFront-Viewer-Country",
                                "Origin",
                                "Referer"]
                        ),
                    MaxTTL = 86400,
                    MinTTL = 14400,
                    DefaultTTL = 43200,
                    ViewerProtocolPolicy = "redirect-to-https",
                    Compress = True,
                ),

这似乎可以很好地构建json模板。但我也需要转发饼干。在QueryString行之后,我插入了Cookies = "All",但是构建失败了。

错误信息:

TypeError: <class 'troposphere.cloudfront.ForwardedValues'>: None.Cookies is <class 'str'>, expected <class 'troposphere.cloudfront.Cookies'>

我需要添加什么,这样它才不会使生成和转发cookie失败。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-11 06:43:24

我在看完这个文档后就把它写好了

在行QueryString = True,之后,我添加了

Cookies = Cookies(Forward = "all"),和它现在构建时没有错误,并将正确的cookie值添加到json模板中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56979350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档