openMF/community-app

baseApiUrl

vorburger opened this issue · 4 comments

Unless I'm missing / misunderstanding something, as far as I can see after looking at the current src, the URL for the back-end API is currently hard-coded to be ""/mifosng-provider/api/v1" - so same host & same port, absolute URL?

This is a shame - one would like to / should be able to easily work locally on the prototype-app without having to know anything about the back-end - we have a back-end running in the cloud - so I'd like to (have the option to) be able to just use that.

That's exactly what the "classic" UI allows with the baseApiUrl query parameter, of course. Could we have that on the prototype-app as well?

The few lines of util code to make this happen should probably be shared between AuthenticationService.js and ResourceFactoryProvider.js? Currently both have the hard-coded "/mifosng-provider/api/v1" String duplicated, which is not ideal. (ResourceFactoryProvider has a baseUrl, but that seems to be used in / built for demoTest.js only.)

I've temporarily locally hacked AuthenticationService and ResourceFactoryProvider and hard-coded 'https://demo.openmf.org/mifosng-provider/api/v1' in them, and that actually works. (I'm not entirely sure if that problem about havig to "ping" the API manually once before is relevant in this context? We should solve that too, somehow.)

Sorry for only ranting and not actually proposing a concrete solution / sending a PR in this case... the problem is I'm not entirely sure that the best way is to read a baseApiUrl-like parameter from the URL inside a service an AngularJS app? $location service? Does that work with the router? The $routeParams thing? Maybe I'll try figuring this out when I have more some other night - if anybody gets to this before me - please do!

@avikganguly01 is looking into this in #335

Thank You @avikganguly01 for #335, and @Nayan for integrating - this works now - closing this (I'll just send a PR for some README clean-up related to this).

PS: There is actually a problem left with the port number.. discussed it with Avik on IM..