| .. | .. |
|---|
| 1 | 1 | import { LocalStorageService } from 'angular-2-local-storage'; |
|---|
| 2 | 2 | import { Injectable } from '@angular/core'; |
|---|
| 3 | | -import { BaseRequestOptions, RequestOptions, Request, XHRBackend, XHRConnection} from '@angular/http'; |
|---|
| 3 | +import { |
|---|
| 4 | + BaseRequestOptions, |
|---|
| 5 | + BrowserXhr, |
|---|
| 6 | + Request, |
|---|
| 7 | + RequestOptions, |
|---|
| 8 | + ResponseOptions, |
|---|
| 9 | + XHRBackend, |
|---|
| 10 | + XHRConnection, |
|---|
| 11 | + XSRFStrategy |
|---|
| 12 | +} from '@angular/http'; |
|---|
| 4 | 13 | |
|---|
| 5 | 14 | |
|---|
| 6 | 15 | // TODO: Chnage this to use Covalent Http helper service |
|---|
| .. | .. |
|---|
| 17 | 26 | let token = this.store.get<string>('token'); |
|---|
| 18 | 27 | if (token) { |
|---|
| 19 | 28 | this.headers.set('X-SECURIS-TOKEN', token); |
|---|
| 29 | + |
|---|
| 20 | 30 | } |
|---|
| 21 | 31 | |
|---|
| 22 | 32 | } |
|---|
| .. | .. |
|---|
| 24 | 34 | |
|---|
| 25 | 35 | @Injectable() |
|---|
| 26 | 36 | export class ApiXHRBackend extends XHRBackend { |
|---|
| 37 | + |
|---|
| 38 | + constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy) { |
|---|
| 39 | + super(_browserXHR, _baseResponseOptions, _xsrfStrategy); |
|---|
| 40 | + } |
|---|
| 41 | + |
|---|
| 27 | 42 | createConnection(request: Request): XHRConnection { |
|---|
| 28 | | - if (request.url.startsWith('/')){ |
|---|
| 29 | | - // request.url = '/securis' + request.url; // prefix base url |
|---|
| 43 | + if (!request.url.endsWith('.js') && !request.url.endsWith('.html') && !request.url.endsWith('.svg')){ |
|---|
| 44 | + request.url = 'http://localhost:8080/securis/' + request.url; // prefix base url |
|---|
| 30 | 45 | } |
|---|
| 31 | 46 | return super.createConnection(request); |
|---|
| 32 | 47 | } |
|---|