段.javascript发布失败,出现CORS错误
segment.io javascript publish fails with a CORS error
我遇到了一个跨源资源共享(CORS)错误,当我试图加载一个网页的样本"入门"javascript代码段。io的网站。下面是html本身。我没有在我的play 2.1.3服务器上设置任何报头,但我认为这是不必要的,因为其他用户向我保证他们已经运行了这个页面,没有问题。:
<html>
<head>
<script type="text/javascript">
window.analytics=window.analytics||[],window.analytics.methods=["identify","group","track","page","pageview","alias","ready","on","once","off","trackLink","trackForm","trackClick","trackSubmit"],window.analytics.factory=function(t){return function(){var a=Array.prototype.slice.call(arguments);return a.unshift(t),window.analytics.push(a),window.analytics}};for(var i=0;i<window.analytics.methods.length;i++){var key=window.analytics.methods[i];window.analytics[key]=window.analytics.factory(key)}window.analytics.load=function(t){if(!document.getElementById("analytics-js")){var a=document.createElement("script");a.type="text/javascript",a.id="analytics-js",a.async=!0,a.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.io/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n)}},window.analytics.SNIPPET_VERSION="2.0.9",
window.analytics.load("**my_key_here**");
window.analytics.page();
</script>
</head>
<body>
</body>
</html>
当我用浏览器加载这个页面时,我在javascript控制台看到以下错误:
[Error] Failed to load resource: Origin http://localhost:9000 is not allowed by Access-Control-Allow-Origin. (p, line 0)
[Error] XMLHttpRequest cannot load http://api.segment.io/v1/p. Origin http://localhost:9000 is not allowed by Access-Control-Allow-Origin. (localhost, line 0)
任何想法?即使是在节目中。
它可能是一个浏览器扩展,阻止跟踪脚本。你安装了吗?例如,我在Chrome上使用Disconnect,并遇到类似的错误,直到我将我的网站列入白名单。
我看到的错误是XMLHttpRequest cannot load http://api.segment.io/v1/i. The request was redirected to a URL ('about:blank') which has a disallowed scheme for cross-origin requests.
相关文章:
- 在指令控制器中使用$attrs时出现问题
- 在Polymer中使用核心ajax时出现CORS错误
- 在 AngularJS 和 CodeIgniter3 中开机自检数据时出现 CORS 错误
- 使用fabric.fromUrl时出现CORS问题
- ajax请求出现CORS错误
- 加载模板时出现AngularJS、Localhost和CORS错误
- 使用 elasticsearch.js 时出现 CORS 错误
- Amazon S3 CORS 在所有主要浏览器上出现 SVG 问题
- 尝试处理 CORS 请求时出现 ParseError
- 重定向时出现机架 CORS 错误
- 从localhost使用谷歌联系人api创建联系人时出现CORS错误
- 在Azure AD B2C中获取令牌时出现CORS问题(隐含流)
- 从文件//scheme运行的应用程序出现CORS错误
- 招摇失败并出现 CORS 样式错误
- jquery ajax请求api时出现CORS错误
- 段.javascript发布失败,出现CORS错误
- AngularJS soap调用会出现CORS问题
- 使用普通JS AJAX请求访问本地JSON文件时出现CORS错误
- web音频api出现Soundcloud CORS错误
- 让 CORS 与 JQuery 客户端、节点/快速服务器一起工作时出现问题