
[英]How can I reduce the number of API calls (Google Analytics API)
[英]Last night my Google Analytics API calls worked. This morning I'm getting CORS errors
我运行了几个与 Google Analytics API v4 接口的仪表板。 All are web apps running off static S3 buckets, and the dashboards are logged into to Google oAuth through the browser interface (all front end javascript - no node, no backend). 仪表板的所有域都在 Google Cloud Console 中注册为授权,并且已经运行了几个月没有问题。
今天早上(2019-11-19T9:00CET),我开始从 API 调用中收到 CORS 错误:
Access to fetch at 'https://analyticsreporting.googleapis.com/v4/reports:batchGet?alt=json' from origin 'http://localhost:3000' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
在 Safari、Chrome 和 Firefox 中,所有仪表板都运行在几个不同的域(上述消息仅来自 localhost 测试,昨晚也有效),都会发生这种情况(自上次调用以来没有更新)。 Google Cloud Console 尚未更新,API 键是正确的,我仍然可以访问所有属性的 Google Analytics UI。
我知道我可以全部重建它以运行节点服务器以进行 API 调用,但这在昨晚有效,现在它没有 - 我不知道为什么 - 所以我不想花时间重建一切都发现这是一个暂时的错误,或者它仍然不起作用。
Update: With "cors" mode in the request header, I was getting a 405 error ( HTTP method is not allowed by a web server for a requested URL
). 切换到“no-cors”模式(如错误消息中所述)会给我一个 429 错误( Too Many Requests
)。
似乎很奇怪,它把它描述为一个节流问题,当我之前在“cors”模式下看到过这个问题时(而且我似乎没有达到一分钟或每日限制)——我怀疑它实际上是在节流.
它突然开始为我们工作(欧洲中部时间 12:05),所以我想我们可以把它归结为 Google 端的服务器传输/错误配置。 三个小时的人问他们的仪表板为什么不工作。 仍然 - 很高兴它不再或需要在我结束时重建。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.