How can I specify different configuration for the back office based on cloud instance/site?
In my back office I have a custom property editor which accesses another web site's web api. I have a need to vary the url for this other web site based on which cloud site I'm on (local, dev, or live). How can I do this?
I have already specified the url's in my web.config, web.development.xdt.config, and web.live.xdt.config. Is there a way to transfer this information from the server side to the client side back office?
I've got the config transforms under control, and it's working well in the back-end of my "front-end" site. And I'm passing the config data (the url) to my client side javascript code via Razor.
The challenge is the client-side Angular code for the back-office custom property editor. How can I replace the "domain" string literal in the code snippet below with values from web.config (or somewhere else)?
angular.module('umbraco')
.controller('productid.editorcontroller', function($scope, $http) {
$scope.search = function(id) {
var domain = 'https://www.myothersite.com';
var url = domain + '/api/products/' + id;
$http.get(url)
.then(
function onSuccess(response) {
},
function onError(response) {
}
);
};
});
Umbraco provides access to something called Umbraco.Sys.Variables in angular which you can hook into during some of the startup events. In there you can add your own behaviour and as a result you might be able to put in the base URL of your API end point. Have a read, it might help :-) You could use the premise to read the domain from an AppSetting populated by a config transform.
How can I specify different configuration for the back office based on cloud instance/site?
In my back office I have a custom property editor which accesses another web site's web api. I have a need to vary the url for this other web site based on which cloud site I'm on (local, dev, or live). How can I do this?
I have already specified the url's in my web.config, web.development.xdt.config, and web.live.xdt.config. Is there a way to transfer this information from the server side to the client side back office?
-Tor
Hi Tor!
Config transforms are your friend. There's documentation and videos about that feature here: https://our.umbraco.com/documentation/Umbraco-Cloud/Set-Up/Config-Transforms/
Hope this helps!
/n
Hi Niels,
I've got the config transforms under control, and it's working well in the back-end of my "front-end" site. And I'm passing the config data (the url) to my client side javascript code via Razor.
The challenge is the client-side Angular code for the back-office custom property editor. How can I replace the "domain" string literal in the code snippet below with values from web.config (or somewhere else)?
Hey Tor,
I wrote a post about something that might help with this.
https://www.justnik.me/blog/accessing-config-settings-in-your-umbraco-angular-controller
Umbraco provides access to something called
Umbraco.Sys.Variables
in angular which you can hook into during some of the startup events. In there you can add your own behaviour and as a result you might be able to put in the base URL of your API end point. Have a read, it might help :-) You could use the premise to read the domain from an AppSetting populated by a config transform.Nik
Thanks Nik! I'll definitely look into this.
-Tor
is working on a reply...