Reputation: 21895
My JavaScript app communicates with a RESTful API that I built which lives on another domain. Locally, the API (Sinatra-based) lives at localhost:9292, and the web site is at localhost:3000.
In production, the API is at api.mydomain.com, and the web site is at admin.mydomain.com.
Everything is fine in local dev mode...cookies are sent to the API with each AJAX request when I look at the "headers" tab for requests under Chrome. However, in production mode, cookies simply are not sent with requests. And the cookie does in fact exist for admin.mydomain.com.
I understand the following JavaScript should make cookies be sent cross-domain with requests -- am I missing something?
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
options.crossDomain = {
crossDomain: true
};
options.xhrFields = {
withCredentials: true
};
});
Any ideas what's wrong?
Upvotes: 0
Views: 252