rsanchez
2017-04-17 c991ebaa5f985eb244890ec438d9a7312df45ba6
#0 fix - Changed tomcat url only in dev mode
1 files modified
changed files
securis/src/main/webapp/src/app/common/default.requests.options.ts patch | view | blame | history
securis/src/main/webapp/src/app/common/default.requests.options.ts
....@@ -10,6 +10,7 @@
1010 XHRConnection,
1111 XSRFStrategy
1212 } from '@angular/http';
13
+declare var window: any;
1314
1415
1516 // TODO: Chnage this to use Covalent Http helper service
....@@ -30,8 +31,12 @@
3031 @Injectable()
3132 export class ApiXHRBackend extends XHRBackend {
3233
34
+ localhostEnv : boolean = false;
35
+ static DEV_TOMCAT_URL : String = 'http://localhost:8080/securis/';
36
+
3337 constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy, private store: Locker) {
3438 super(_browserXHR, _baseResponseOptions, _xsrfStrategy);
39
+ this.localhostEnv = window.location.href.startsWith("http://localhost");
3540 }
3641
3742 createConnection(request: Request): XHRConnection {
....@@ -39,8 +44,8 @@
3944 if (token) {
4045 request.headers.set('X-SECURIS-TOKEN', token);
4146 }
42
- if (!request.url.endsWith('.js') && !request.url.endsWith('.json') && !request.url.endsWith('.html') && !request.url.endsWith('.svg')){
43
- request.url = 'http://localhost:8080/securis/' + request.url; // prefix base url
47
+ if (this.localhostEnv && !request.url.endsWith('.js') && !request.url.endsWith('.json') && !request.url.endsWith('.html') && !request.url.endsWith('.svg')){
48
+ request.url = ApiXHRBackend.DEV_TOMCAT_URL + request.url; // prefix base url
4449 }
4550 return super.createConnection(request);
4651 }