Google App Engine无法在服务之间设置https浏览器Cookie

问题描述 投票:0回答:1

我在Google Cloud(App Engine)上部署了一个带有两个服务的应用程序(一个前端--React和一个后端 - 带有Express的NodeJS)。我们在仅https连接上设置cookie有问题。使用http设置cookie。 Google为http(http://somedomain.someid.appspot.com)提供了两个域,为https(https://somedomain-dot-someid.appspot.com)提供了一个域。请注意区别。我们使用谷歌的通配符证书。

无论我在cookies中设置了什么域名('https://somedomain-dot-someid.appspot.com','。somedomain-dot-someid.appspot.com','。appspot.com'),Cookie总是设置为.someid.appspot.com。我看到当我在浏览器中打开后端url('someid.appspot.com')但未在前端URL中设置cookie时。

我想问题是我无法在somedomain-dot-someid.appspot.com上设置cookie,因为它不是子域名(如果我使用http版本 - http://somedomain.someid.appspot.com)它是子域名。

如何在https://somedomain-dot-someid.appspot.comhttps://someid.appspot.com上设置cookie?

谢谢

google-app-engine cookies https subdomain wildcard-subdomain
1个回答
1
投票

您可以使用自定义域和每个服务的不同子域执行此操作。例如,使用www.example.com作为前端,使用service.example.com作为后端。

对于每个服务,您应该能够将cookie设置为对应于域(example.com)而不是子域。然后,在另一项服务上将提供在一项服务上设置的cookie。

© www.soinside.com 2019 - 2024. All rights reserved.