Reputation: 545
I'm using Ember App Kit trying to build an application that logs into an existing server. My problem is that I'm getting the following message:
XMLHttpRequest cannot load https://example.server.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.
I've Googled this around and it seems that I need to add/enable CORS in my express-server. I've tried following various samples, such as:
But I couldn't get it to run.
In short I'm trying to find a sample of how should I add the CORS onto my express-server
Cheers,
Dror
Upvotes: 0
Views: 521
Reputation: 545
Eventually I dodged the bullet by using an already running server to serve my ember project.
Thank you kiwiupover and ulisesrmzroche for a timely response
Upvotes: 0
Reputation: 145
Stick this inside your Em.Application.extend, inside the ready hook
$(document).ajaxSend(function (event, xhr, settings) {
settings.xhrFields = {
withCredentials: true
};
});
For express, try using the cors module on npm. https://www.npmjs.org/package/cors. It should all work out of the box.
Upvotes: 1