Resolving cross-domain calls with grunt yoman (1.0) server

I use Yeoman 0.9 until yesterday, when I decided to use beta version 1.0 on OS X. I use Yeoman to develop the angular application.

With porting my application Yeoman 0.9 → 1.0 and working, I now want to expand the dev server launched by the grunt server yoman . let me make cross-domain API calls developed by another team hosted on a different server, where they already allowed cross-domain calls. So far, we have used the fake http backend from angular.js.

- Aside -

If someone reads this for a quick fix, we get cross-domain calls that work by passing the option - disable-web-security in Chrome from the command line using this approach in OS X with Chrome, but it disables protection for all Chrome (with large fingers), and we can't get Chrome to start as a new instance anyway.

- end to side -

After some digging, I found this post (through the answer to this post ) giving me a pretty good idea of ​​what I need to do to get a grunt server that allows cross-domain calls. This is essentially due to the addition of a middleware component for the connection that allows you to change the headers so that "Access-Control-Allow-Origin" is set to "*" or whatever.

I don’t know anything about Node.js, I see that the change mentioned in the message should be made somewhere in many files created by Yeomen, but where? I searched the raw string for "app.configure" and "connect.listen" in the "node_modules" directory created by Yeoman, but I came up with a few hits, most of which are taken from examples bundled with modules, and I don’t understand what I should edit. In case this helps, here is a snapshot of the directory structure for my angular application:

enter image description here

If someone can give me some pointers on where these changes can be made, I would really appreciate it!

+6
source share
2 answers

Solved without using node using the approach in this request on github pull: http://github.com/angular/angular.js/pull/1454

+2
source

You can use the Apache proxy and connect the REST server using gruntjs (angular.js).

Apache will do the following:

  • proxy / -> gruntjs
  • proxy / service → REST server

you would use an application that got into Apache and the angular.js application would think it was talking to itself, so there is no problem with the cross domain.

Here is a great setup tutorial: http://alfrescoblog.com/2014/06/14/angular-js-activiti-webapp-with-activiti-rest/

+1
source

All Articles