Cookies and `ember serve`


#1

In dev we are trying to send a cookie to a server, but in chrome and safari the cookie is not being sent by the browser.

Our server is hosted at https://foo.bar.example.com and we have added a /etc/hosts entry on our dev machines to map localhost to ember.bar.example.com. We have generated a self signed cert for our dev machines to we can access our app via https://ember.bar.example.com.

we login to the server at https://foo.bar.example.com via a different app and it sets several cookies, some are scoped to .example.com and others to .bar.example.com. Only one of these cookies is secure, but none of the cookies are sent to the server from our ember app.

At this point we expect the cookies to get sent to https://foo.bar.example.com when our ember app makes requests to that server, but the cookies aren’t sent. We do have “ssl”: true, set in .ember-cli and our ssl certs are in the ssl directory at the root of our app.

If I understand correctly port numbers are important to cookies so as a trouble shooting step we setup a ProxyPass in Apache so that we could load our ember app from https://ember.bar.example.com and exclude the port number. The cookies still weren’t sent.

Can anyone help me understand one the cookies aren’t being sent or more trouble shooting steps?

Thanks!


#2

What are you using to send the request? Jquerys Ajax, ember-ajax, fetch?


#3

Thanks Troy.

We’ve tired jQuery AJAX via the console, and I assume ember-Ajax via ember data.


#4

Even though we are same origin the solution was to add withCredentials to the ajax setup:

Ember.$.ajaxSetup({
  xhrFields: {
    withCredentials: true,
  },
});