In configuring my API endpoint and URL's, I utilize a custom app.config.js file with environment variables:
angular.module('api-config', []).constant('ENV',
{
name: 'My Project Name',
apiEndPoint: 'http://SOMEIP/gateway/',
apiListUser: '/user',
apiUser: '/user/{:id}'
});
Controller
var servicePath = ENV.apiEndPoint;
var listUserApi = ENV.apiListUser;
return $http({
method: 'POST',
url: servicePath + listUserApi
})
Challenges faced by the current approach:
External developers or consultants gain access to private configuration data stored in the config.
Limited scalability due to fixed configuration preventing dynamic scaling and application customization during deployment.
Goals for improvement:
- Deploying AngularJS applications in various environments (staging, production) with different configurations without altering the code.
- Sharing AngularJS application code externally while protecting confidential details by separating all configuration in a distinct app.config.js file. Is this the most secure method?
- Avoiding exposure of API endpoints and URLs in the app.config.js file to any developer viewing the source code. How can this be prevented?