Question

I work on a app using angular.dart at the clientside and dart in the serverside. I have write a login rest entrypoint and want to set cookies the header was in the response but the cookies are not set.

set-cookie:app-user=533c1470a2658184a7625d7d; Expires=Tue, 8 Apr 2014 9:15:47 GMT; Domain=.ballr.eu; Path=/
set-cookie:app-tokn=530fa71b615e168787a7cb5b5c589a5601065e1e3f921d4b770c784394de3a42; Expires=Tue, 8 Apr 2014 9:15:47 GMT; Domain=.ballr.eu; Path=/

I try to check my headers or my value set in cookies, but to my mind is good

headers :

request.response..statusCode=HttpStatus.OK
                ..headers.set(HttpHeaders.CONTENT_TYPE, 'text/plain: charset=UTF-8')
                ..headers.add("Access-Control-Allow-Methods", "OPTIONS, GET, POST, PUT, DELETE")
                ..headers.add("Access-Control-Allow-Headers", "origin, x-requested-with, content-type, accept")
                ..headers.add("Access-Control-Allow-Origin", "*");

cookies :

static setCookie(HttpRequest request, String key, String value, DateTime duration) => 
  request.response.cookies.add(new Cookie(key, value)..path  = '/'
                                                  ..expires  = duration
                                                  ..domain   = '.app.eu');

I follow some threads on stackoverflow and google groups and I think it's a problem of "withCredientals" a value I have set in an another projet (angular/Java) but I don't find this parameter on angular.dart.

Can you help me to find it or have you somes ideas?

Thank you for your help/time

Was it helpful?

Solution

I'm not sure if I understand you question correctly but maybe this is what you are looking for:

(on the client)

  var request = new HttpRequest()
    ..open("POST", uri.toString(), async: true)
    ..withCredentials = true // seems to be necessary so that cookies are sent

EDIT
I missed that this is about Angular. This needs a slightly different approach.

If you use the Angular http service you have a parameter

class MyController {
  Http _http;
  MyController(this._http) {
    _http.getString('someurl', withCredentials: true).then((e) => ...);
    // or _http.request('someurl', method: 'POST', withCredentials: true).then((e) => ...);
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top