Setting cookies for subdomain

后端 未结 2 452
时光取名叫无心
时光取名叫无心 2020-12-20 07:40

i\'m making a web app in a restful way. For my client side i\'m using angularJs, the same is hosted at - lets say - https://domain.com

My backend is built on spring

相关标签:
2条回答
  • 2020-12-20 08:12

    The problem you're describing is related to cross domain cookie policies. I don't know your exact use-case, but looking at CORS and P3P headers should give you a good start. As an option, you can try setting your cookie manually via Javascript.

    0 讨论(0)
  • 2020-12-20 08:27

    Making CORS working isn't enough, you also need to enable withCredentials in angular.

    https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials

    Example:

    angular.module('example', []).config(function ($httpProvider) {
        $httpProvider.defaults.withCredentials = true;
    });
    
    0 讨论(0)
提交回复
热议问题