Axios 也为子域发送 cookie

Axios sending cookies for subdomain as well

提问人:Srinivas 提问时间:11/15/2023 最后编辑:Srinivas 更新时间:11/15/2023 访问量:25

问:

我创建了一个应用程序并托管在开发和生产中。这是 url 的样子,.我的服务器发送 cookie 并将 cookie 域设置为 和 。所有 Cookie 都设置为 和 、 。app.hello.comapp.dev.hello.comhello.comdev.hello.comHTTPOnlySecure: trueSamesite:Lax

我正在使用 axios,并设置为读取 cookie 并将其发送到请求标头中。withCredentials:true

  • 当我打开时,只有 cookie 被发送到服务器。app.hello.comhello.com
  • 当我打开时,所有cookie都有,或者发送到服务器。我需要将其限制为仅.app.dev.hello.comhello.comdev.hello.comdev.hello.com

我该怎么做?

JavaScript Cookie Axios

评论

0赞 CBroe 11/15/2023
developer.mozilla.org/en-US/docs/Web/HTTP/Headers/...: “设置域将使 cookie 可供其使用,也可用于其所有子域。如果省略,则此属性默认为当前文档 URL 的主机,不包括子域。

答: 暂无答案