Fineract backend settings with environment variables
This commit is contained in:
committed by
Arnold Gálovics
parent
1b72136411
commit
14ceb4f3fd
@@ -6,23 +6,27 @@ import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/c
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/** Environment Configuration */
|
||||
import { environment } from 'environments/environment';
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
|
||||
/**
|
||||
* Http request interceptor to prefix a request with `environment.serverUrl`.
|
||||
* Http request interceptor to prefix a request with `serverUrl`.
|
||||
*/
|
||||
@Injectable()
|
||||
export class ApiPrefixInterceptor implements HttpInterceptor {
|
||||
/**
|
||||
* @param {SettingsService} settingsService Settings Service
|
||||
*/
|
||||
constructor(private settingsService: SettingsService) {}
|
||||
|
||||
/**
|
||||
* Intercepts a Http request and prefixes it with `environment.serverUrl`.
|
||||
* Intercepts a Http request and prefixes it with `serverUrl`.
|
||||
*/
|
||||
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
/**
|
||||
* Ignore URLs that are complete for i18n
|
||||
*/
|
||||
if (!request.url.includes('http:') && !request.url.includes('https:')) {
|
||||
request = request.clone({ url: environment.serverUrl + request.url });
|
||||
request = request.clone({ url: this.settingsService.serverUrl + request.url });
|
||||
}
|
||||
|
||||
return next.handle(request);
|
||||
|
||||
Reference in New Issue
Block a user