我发现自己很难使用grunt-connect-proxy从我的yeoman生成的调用端口9000上运行的角度应用程序调用我的laravel后端运行在端口8000上。遵循grunt-connect-proxy上的说明github我在运行grunt serve时看到以下消息:
Running "configureProxies:server" (configureProxies) task
Proxy created for: /api to localhost:8000
我在connect.proxies中直接在connect.options:
之后设置了我的代理proxies: [{
context: '/api', // the context of the data service
host: 'localhost', // wherever the data service is running
port: 8000 // the port that the data service is running on
}],
在我的控制器中然后尝试调用api来测试我的代理:
var Proxy = $resource('/api/v1/purchase');
Proxy.get(function(test){
console.log(test);
});
在我的控制台中的结果是500错误,表示仍然调用端口9000而不是8000:
http://localhost:9000/api/v1/purchase 500 (Internal Server Error)
以下是指向包含我的完整gruntfile的要点的链接:https://gist.github.com/JohnBueno/7d48027f739cc91e0b79
我已经看过很多关于此的帖子,但到目前为止,没有一个帖子对我有任何帮助。