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