Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Hyperagent和apache玩得不好_Javascript_Apache_.htaccess_Cross Domain - Fatal编程技术网

Javascript Hyperagent和apache玩得不好

Javascript Hyperagent和apache玩得不好,javascript,apache,.htaccess,cross-domain,Javascript,Apache,.htaccess,Cross Domain,我通过hyperagent.js在一个从旧服务器转移过来的站点上调用API 基本上,脚本是从HAL资源调用外部URL,hyperagent应该让我操作数据。我的代码hyperagent的以下部分失败: var api = new Hyperagent.Resource('http://my.api.com/'); api.fetch() <--fails here .then(function (root) { console.log('API root r

我通过hyperagent.js在一个从旧服务器转移过来的站点上调用API

基本上,脚本是从HAL资源调用外部URL,hyperagent应该让我操作数据。我的代码hyperagent的以下部分失败:

var api = new Hyperagent.Resource('http://my.api.com/');

api.fetch()   <--fails here
    .then(function (root) {  
       console.log('API root resolved:', root);
       apiRoot = root;
       return root.link('abf:brands-embed', { fields: 'abf:hotel.id,abf:hotel.lat,abf:hotel.lng'}).fetch();
})
.catch(function (err) {  <--caught here
  console.warn('Error fetching API root', err);
});
var-api=new-Hyperagent.Resource('http://my.api.com/');

api.fetch()您是否尝试过删除
/
,以便它只发送标题?在浏览器devtools控制台中,没有任何消息被记录?请澄清:这是服务环境中的.htaccess代码段吗?你有那个环境的配置权限吗?@sideshowbarker是的,什么都没做。API一直在不同的页面上工作,研究这个问题。@sideshowbarker我有开发工具,从hyperagent那里得到了一个看起来毫无意义的对象。htaccess文件位于主域上,而不是API上。正在检查API的.htaccess文件
<FilesMatch "\.(ttf|otf|eot|woff)$">
  <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
  </IfModule>
</FilesMatch>