Angularjs 爱奥尼亚拉维API发布

Angularjs 爱奥尼亚拉维API发布,angularjs,laravel,xmlhttprequest,Angularjs,Laravel,Xmlhttprequest,我正在努力满足以下要求: var spice = $http.put("http://localhost:8000/api/v1/Spices/", sanitizeSpice(spice, id)); 其中sanitizeSpice返回类似{amount:“54”,id:“2”) 我得到以下错误: XMLHttpRequest cannot load http://localhost:8000/api/v1/Spices/. No 'Access-Control-Allow-Origin'

我正在努力满足以下要求:

var spice = $http.put("http://localhost:8000/api/v1/Spices/", sanitizeSpice(spice, id));
其中sanitizeSpice返回类似{amount:“54”,id:“2”)

我得到以下错误:

XMLHttpRequest cannot load http://localhost:8000/api/v1/Spices/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. 
我在Laravel中设置了以下过滤器(如我在这里找到的其他示例所示):


我做错了什么?我没有发现POST、get或DELETE的错误。请提前感谢!

如果您使用谷歌访问控制允许源站,第一个点击是

您需要在nginx或apache2配置中允许ajax调用

使用谷歌为它们找到好的配置。 例如,对于nginx:

add_header 'Access-Control-Allow-Origin' '*';

我已经在谷歌上搜索过好几次了。允许ajax调用。仍然给出错误。你把add_头行放在哪里了?试着发布整个nginx/apache2配置。
add_header 'Access-Control-Allow-Origin' '*';