Seeking help to resolve an issue we've encountered. Despite trying various solutions, we keep encountering the Access-Control-Allow-Origin error when attempting to access keen.
Error message: Failed to load resource: the server responded with a status of 404 (Not Found) admin:1 XMLHttpRequest cannot load /queries/. Response for preflight has invalid HTTP status code 404
Snippet from admin.js:
<script type="text/javascript>
var client = new Keen({
projectId: "id", // String (required always)
writeKey: "key", // String (required for sending)
readKey: "key", // String (required for querying)
// protocol: "https", // String (optional: https | http | auto)
// host: "api.keen.io/3.0", // String (optional)
requestType: "jsonp" // String (optional: jsonp, xhr, beacon)
});
Keen.ready(function() {
var metric = new Keen.Query("newBusiness", {
analysisType: "count",
timeframe: "this_1_month"
});
client.draw(metric, document.getElementById("newBusiness-count-chart"), {
chartType: "metric",
label: "Count of Businesses"
});
});
List of headers and origins used:
app.all('*', function (req, res, next) {
res.header('Access-Control-Allow-Origin', 'https://api.keen.io:443, fonts.googleapis.com');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, Origin, X-Requested-With, Accept');
res.header('Access-Control-Allow-Credentials', true);
res.header('Access-Control-Allow-withCredentials', true);
next();
});