From fe067807c714aa4575880686d2dcf162a2aa1fe7 Mon Sep 17 00:00:00 2001 From: unSinn Date: Fri, 30 Aug 2013 15:57:57 +0200 Subject: [PATCH] Polling a value via Ajax (jQuery) produces "Origin http://aitec is not allowed by Access-Control-Allow-Origin." Complete Error from Chromium: "XMLHttpRequest cannot load http://192.168.2.200/json/output_light. Origin http://aitec is not allowed by Access-Control-Allow-Origin." I don't know if this is the proper fix for this but it's working for me. thanks for a great Arduino library --- rest_server.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_server.cpp b/rest_server.cpp index 229e090..e00e104 100644 --- a/rest_server.cpp +++ b/rest_server.cpp @@ -628,7 +628,7 @@ void RestServer::print_json(Stream &_client) { } void RestServer::print_resource_description(Stream &_client) { - print_flash_string(PSTR("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n"), _client); + print_flash_string(PSTR("HTTP/1.1 200 OK\r\nAccess-Control-Allow-Origin: *\r\nContent-Type: application/json\r\n\r\n"), _client); print_flash_string(PSTR("[\r\n"), _client); for(byte i = 0; i < int(resources_count); i++) { @@ -729,4 +729,4 @@ boolean RestServer::match_eol_char(char _new_char) { if (_new_char == eol_sequence[i]) return true; } return false; -} \ No newline at end of file +}