I'm developing my first web app, using grunt, yo, angular.js, ... I also need some server-side service (which I will implement in PHP).
Which is the "standard" way to handle this scenario, which is - I suppose - quite widespread?
I mean, a setup which can be used both during development (grunt server for client-side, and apache for server-side) and production (apache or nginx server for both client-side and server side).
I make an example to clarify my doubts: I have an angular service like this:
var serverUrl = '//localhost:80';
app.factory('myFactory', function($resource) {
$resource(serverUrl + '/api/getDataFromServer/:reqId', { ... }
);
While developing, I have two distinct servers for client-side (grunt on port 9000, for example), and server-side (apache on port 80, for example), so - to avoid CORS issues - I will have to - at least - add a header("Access-Control-Allow-Origin: http://localhost:9000")
to server (JSON) output.
In production, conversely, I will have a single server to serve both static (angular app) and dynamic (data from PHP) content, so I will not need any additional Access-Control meta tag...
Of course I can take the current environment status (development / production) into account, and accordingly output or not the additional meta tag...
My question is: is this approach common with web apps (which need custom data services)? Do you follow a different approach, or do you see any 'architectural' improvement possible with this design?