2

I am finding myself pretty stuck using grunt-connect-proxy to make calls from my yeoman generated angular app running on port 9000 to my laravel backend which is running on port 8000. After following the instructions on the grunt-connect-proxy github I see the following message upon running grunt serve:

Running "configureProxies:server" (configureProxies) task
Proxy created for: /api to localhost:8000

I have my proxies set up here in connect.proxies directly following 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
}],

In my controller then attempt to make a call to the api to test my proxy:

var Proxy = $resource('/api/v1/purchase');
Proxy.get(function(test){
  console.log(test);
});

In the result of this in my console is a 500 error indicating that the call was still made to port 9000 rather than 8000:

http://localhost:9000/api/v1/purchase 500 (Internal Server Error) 

Here is a link to a gist containing my full gruntfile: https://gist.github.com/JohnBueno/7d48027f739cc91e0b79

I have seen quite a few posts on this but so far none of them have been of much help to me.

Bueno
  • 1,840
  • 2
  • 15
  • 17
  • I have not used $resource yet, but $http.post('/api'....works for me. I also used the exact same configuration from the Readme. – Richard May 22 '14 at 10:31
  • I was able to get this working by changing the config of my apache server to make it run on 0.0.0.0 using: php artisan serve --host 0.0.0.0 This leads me to believe that it is not an issue with the grunt task but more so an issue with communicating with the apache server. – Bueno May 28 '14 at 14:29

0 Answers0