0

Trying to use angular.js and Play Framework 2.1 altogether.

My first step was to install angular.js and yeoman`: npm, bower, .grunt, ... a full js toolkit. Code organization which seemed "standard".

Then I added Play 2.1 Scala version. Code layout follows the standard from PlayFramework

When I want my angular.js services to talk to real REST actions I get CORS problems due to usage of different ports : 9000 (yeoman) and 9001 (play run 9001).

Which are the options available? What are the solutions and why? (I don't think there is an unique or Best solution for this).

The candidates, I know are :

  1. play-yeoman sbt plugins (I didn't succeed with my Windows environnement - be kind please).

  2. CORS workarounds (add .withheader to Play results).

  3. WebJars providing "Maven-like" dependencies for JS libraries.

One last important thing is running tests. We need to run the angularjs test suite (using Karma) easily and we need to run Scala tests too. And, if possible, that someone working with angular can use all the web resources available without too much worrying about its specific environment). The more standard the better, I would say.

Update 1 : The question was meant to discuss the use cases for each solution : their constraints, their appeal, code organization and architecture with multiple applicatons accessing REST Services.

4

1 回答 1

0

You can change the response header in DEV mode: http://rockyj.in/2013/04/01/building_single_page_applications_and_cors.html

I don't see anything else you can do if you're running your assets on another server, or maybe redirect all requests on /assets/* to your other server.

于 2013-07-08T12:12:53.203 回答