From c991ebaa5f985eb244890ec438d9a7312df45ba6 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Mon, 17 Apr 2017 12:53:34 +0000
Subject: [PATCH] #0 fix - Changed tomcat url only in dev mode
---
securis/src/main/webapp/src/app/common/default.requests.options.ts | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/securis/src/main/webapp/src/app/common/default.requests.options.ts b/securis/src/main/webapp/src/app/common/default.requests.options.ts
index 768468e..fd8865a 100644
--- a/securis/src/main/webapp/src/app/common/default.requests.options.ts
+++ b/securis/src/main/webapp/src/app/common/default.requests.options.ts
@@ -10,6 +10,7 @@
XHRConnection,
XSRFStrategy
} from '@angular/http';
+declare var window: any;
// TODO: Chnage this to use Covalent Http helper service
@@ -30,8 +31,12 @@
@Injectable()
export class ApiXHRBackend extends XHRBackend {
+ localhostEnv : boolean = false;
+ static DEV_TOMCAT_URL : String = 'http://localhost:8080/securis/';
+
constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy, private store: Locker) {
super(_browserXHR, _baseResponseOptions, _xsrfStrategy);
+ this.localhostEnv = window.location.href.startsWith("http://localhost");
}
createConnection(request: Request): XHRConnection {
@@ -39,8 +44,8 @@
if (token) {
request.headers.set('X-SECURIS-TOKEN', token);
}
- if (!request.url.endsWith('.js') && !request.url.endsWith('.json') && !request.url.endsWith('.html') && !request.url.endsWith('.svg')){
- request.url = 'http://localhost:8080/securis/' + request.url; // prefix base url
+ if (this.localhostEnv && !request.url.endsWith('.js') && !request.url.endsWith('.json') && !request.url.endsWith('.html') && !request.url.endsWith('.svg')){
+ request.url = ApiXHRBackend.DEV_TOMCAT_URL + request.url; // prefix base url
}
return super.createConnection(request);
}
--
Gitblit v1.3.2