rsanchez
2017-04-17 19be37d4112b9c1ff2568af4c652deccd4c0b3c5
securis/src/main/webapp/src/app/common/default.requests.options.ts
....@@ -10,8 +10,7 @@
1010 XHRConnection,
1111 XSRFStrategy
1212 } from '@angular/http';
13
-declare var window: any;
14
-
13
+import { IS_DEV_MODE } from './session';
1514
1615 // TODO: Chnage this to use Covalent Http helper service
1716 // https://www.npmjs.com/package/@covalent/http
....@@ -31,12 +30,10 @@
3130 @Injectable()
3231 export class ApiXHRBackend extends XHRBackend {
3332
34
- localhostEnv : boolean = false;
3533 static DEV_TOMCAT_URL : String = 'http://localhost:8080/securis/';
3634
3735 constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy, private store: Locker) {
3836 super(_browserXHR, _baseResponseOptions, _xsrfStrategy);
39
- this.localhostEnv = window.location.href.startsWith("http://localhost");
4037 }
4138
4239 createConnection(request: Request): XHRConnection {
....@@ -44,7 +41,7 @@
4441 if (token) {
4542 request.headers.set('X-SECURIS-TOKEN', token);
4643 }
47
- if (this.localhostEnv && !request.url.endsWith('.js') && !request.url.endsWith('.json') && !request.url.endsWith('.html') && !request.url.endsWith('.svg')){
44
+ if (IS_DEV_MODE && !request.url.endsWith('.js') && !request.url.endsWith('.json') && !request.url.endsWith('.html') && !request.url.endsWith('.svg')){
4845 request.url = ApiXHRBackend.DEV_TOMCAT_URL + request.url; // prefix base url
4946 }
5047 return super.createConnection(request);