需要帮助解决此问题。我们尝试了很多不同的东西,但由于某种原因,访问控制允许来源不允许来源错误在尝试访问敏锐时不断弹出
加载资源失败:服务器响应状态为 404 (Not Found) admin:1 XMLHttpRequest cannot load https://api.keen.io/3.0/projects/ /queries/。预检响应具有无效的 HTTP 状态代码 404
这是 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"
});
});
这些我们是标题和起源
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();
});