| .. | .. |
|---|
| 10 | 10 | XHRConnection, |
|---|
| 11 | 11 | XSRFStrategy |
|---|
| 12 | 12 | } from '@angular/http'; |
|---|
| 13 | +declare var window: any; |
|---|
| 13 | 14 | |
|---|
| 14 | 15 | |
|---|
| 15 | 16 | // TODO: Chnage this to use Covalent Http helper service |
|---|
| .. | .. |
|---|
| 30 | 31 | @Injectable() |
|---|
| 31 | 32 | export class ApiXHRBackend extends XHRBackend { |
|---|
| 32 | 33 | |
|---|
| 34 | + localhostEnv : boolean = false; |
|---|
| 35 | + static DEV_TOMCAT_URL : String = 'http://localhost:8080/securis/'; |
|---|
| 36 | + |
|---|
| 33 | 37 | constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy, private store: Locker) { |
|---|
| 34 | 38 | super(_browserXHR, _baseResponseOptions, _xsrfStrategy); |
|---|
| 39 | + this.localhostEnv = window.location.href.startsWith("http://localhost"); |
|---|
| 35 | 40 | } |
|---|
| 36 | 41 | |
|---|
| 37 | 42 | createConnection(request: Request): XHRConnection { |
|---|
| .. | .. |
|---|
| 39 | 44 | if (token) { |
|---|
| 40 | 45 | request.headers.set('X-SECURIS-TOKEN', token); |
|---|
| 41 | 46 | } |
|---|
| 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 |
|---|
| 44 | 49 | } |
|---|
| 45 | 50 | return super.createConnection(request); |
|---|
| 46 | 51 | } |
|---|