REST API - cross domain - CORS
scottsuine opened this issue · 1 comments
I have installed ouimeaux on a rapsberry pi and it is working great. It detects all wemo devices (15) and I can control them through the CLI and via URL REST API calls form the browser.
However, when trying to access the REST API through AJAX. I receive the following error
XMLHttpRequest cannot load http://192.168,0.109:5000/api/environment. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://smarthome.suine' is therefore not allowed access.
the AJAX I am using to call is this
$(function () {
$.ajax({
url: 'http://192.168.0.109:5000/api/environment',
type: 'GET',
dataType: 'json',
}).done(function(data) {
JSON.stringify(data);
//console.log('success', data);
});
});
It appears this is because i need to make the call cross domain, even though my webserver is on the same server as Ouimeaux. I have read up on CORS which seems to deal with this when the server is a standard web server such as Apache. but how do I enable this on the Ouimeaux server?
Or is there another way to make the REST API calls to get around this
thanks
Fixed this by adding CORs support to app