All,
Firstly, running CumulusMX 3.8.4 running on a Raspberry Pi.
I am attempting to perform an API query to the Pi from a new website such as http://IPAddress:8998:/api/todayyest/temp.json using the $.get function in JavaScript. I have tried the same query from the website running on localhost too. With with same result.
The query works from a browser request, just not from the code on my new site.
I am getting an error saying "request has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource."
The Internet says that basic calls like $.get should work and only complex queries generate such errors.
Couple of questions.
How/what web thingy is running on CumulusMX to serve up the 'Interface'.
How can I allow a cross site request to CumulusMX on the Pi.
Whilst I do have Apache running on the Pi now, it wasn't installed as part of the CumulusMX install so I believe that CumulusMX is not using it.
Regards
Peter
Welcome to the Cumulus Support forum.
Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)
Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki
If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080
Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)
Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki
If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080
CORS Error
Moderator: daj
-
peterjreid61
- Posts: 15
- Joined: Sat 13 Oct 2018 7:00 am
- Weather Station: Davis Vantage Vue
- Operating System: Raspberry Pi
- Location: Newcastle, Australia
- Contact:
- mcrossley
- Posts: 14384
- Joined: Thu 07 Jan 2010 9:44 pm
- Weather Station: Davis VP2/WLL
- Operating System: Bullseye Lite rPi
- Location: Wilmslow, Cheshire, UK
- Contact:
Re: CORS Error
Are you sending the correct CORS header with the main page to permit the access to the second site?
-
peterjreid61
- Posts: 15
- Joined: Sat 13 Oct 2018 7:00 am
- Weather Station: Davis Vantage Vue
- Operating System: Raspberry Pi
- Location: Newcastle, Australia
- Contact:
Re: CORS Error
Thanks for replying.
I don't believe I am and I have spent days looking to see what that should be with no luck.
I have tried various code blocks but always get a similar error.
Am I correct in reading that the destination has to be configured to permit a request.
The code blocks I have tried are:
function query1() {
// test cross domain ajax
$.get("http://192.168.1.1:8998/api/graphdata/units.json").done(function (data) {
console.log(data);
});
function query2(){
$.ajax({
url: "http://192.168.1.1:8998/api/graphdata/units.json",
data: "", //data to be sent to server
contentType: "application/json; charset=utf-8",
type: "GET",
crossDomain: true,
success: function (data) {
logObject(data);
alert(data);
},
error: function (x, y, z) {
alert(x.responseText +" " +x.status);
}
});
return data;
function query3() {
var data;
$.get("http://192.168.1.1:8998/api/graphdata/units.json"), function(response) {
data=response;
logObject(response);
}
return data;
}
function query4(){
$.ajax({
type: "GET",
headers: {"X-My-Custom-Header": "X"},
url: "http://192.168.1.1:8998/api/graphdata/units.json"
}).done(function (data) {
console.log(data);
return data;
});
}
I don't believe I am and I have spent days looking to see what that should be with no luck.
I have tried various code blocks but always get a similar error.
Am I correct in reading that the destination has to be configured to permit a request.
The code blocks I have tried are:
function query1() {
// test cross domain ajax
$.get("http://192.168.1.1:8998/api/graphdata/units.json").done(function (data) {
console.log(data);
});
function query2(){
$.ajax({
url: "http://192.168.1.1:8998/api/graphdata/units.json",
data: "", //data to be sent to server
contentType: "application/json; charset=utf-8",
type: "GET",
crossDomain: true,
success: function (data) {
logObject(data);
alert(data);
},
error: function (x, y, z) {
alert(x.responseText +" " +x.status);
}
});
return data;
function query3() {
var data;
$.get("http://192.168.1.1:8998/api/graphdata/units.json"), function(response) {
data=response;
logObject(response);
}
return data;
}
function query4(){
$.ajax({
type: "GET",
headers: {"X-My-Custom-Header": "X"},
url: "http://192.168.1.1:8998/api/graphdata/units.json"
}).done(function (data) {
console.log(data);
return data;
});
}