@@ -578,7 +578,6 @@ var BackendService = (function () {
578
578
this . config . host = loc . host ; // default to app web server host
579
579
this . config . rootPath = loc . path ; // default to path when app is served (e.g.'/')
580
580
Object . assign ( this . config , config ) ;
581
- this . setPassThruBackend ( ) ;
582
581
}
583
582
//// protected /////
584
583
/**
@@ -647,8 +646,11 @@ var BackendService = (function () {
647
646
// request is for a collection created by the InMemoryDbService
648
647
return this . createResponse$ ( function ( ) { return _this . collectionHandler ( reqInfo ) ; } ) ;
649
648
}
650
- else if ( this . passThruBackend ) {
649
+ else if ( this . config . passThruUnknownUrl ) {
651
650
// Passes request thru to a "real" backend.
651
+ if ( ! this . passThruBackend ) {
652
+ this . setPassThruBackend ( ) ;
653
+ }
652
654
return this . passThruBackend . handle ( req ) ;
653
655
}
654
656
else {
@@ -1156,22 +1158,19 @@ var HttpBackendService = (function (_super) {
1156
1158
} ) ;
1157
1159
} ;
1158
1160
HttpBackendService . prototype . setPassThruBackend = function ( ) {
1159
- this . passThruBackend = undefined ;
1160
- if ( this . config . passThruUnknownUrl ) {
1161
- try {
1162
- // copied from @angular /http/backends/xhr_backend
1163
- var browserXhr = this . injector . get ( _angular_http . BrowserXhr ) ;
1164
- var baseResponseOptions = this . injector . get ( _angular_http . ResponseOptions ) ;
1165
- var xsrfStrategy = this . injector . get ( _angular_http . XSRFStrategy ) ;
1166
- var xhrBackend_1 = new _angular_http . XHRBackend ( browserXhr , baseResponseOptions , xsrfStrategy ) ;
1167
- this . passThruBackend = {
1168
- handle : function ( req ) { return xhrBackend_1 . createConnection ( req ) . response ; }
1169
- } ;
1170
- }
1171
- catch ( e ) {
1172
- e . message = 'Cannot create passThru404 backend; ' + ( e . message || '' ) ;
1173
- throw e ;
1174
- }
1161
+ try {
1162
+ // copied from @angular /http/backends/xhr_backend
1163
+ var browserXhr = this . injector . get ( _angular_http . BrowserXhr ) ;
1164
+ var baseResponseOptions = this . injector . get ( _angular_http . ResponseOptions ) ;
1165
+ var xsrfStrategy = this . injector . get ( _angular_http . XSRFStrategy ) ;
1166
+ var xhrBackend_1 = new _angular_http . XHRBackend ( browserXhr , baseResponseOptions , xsrfStrategy ) ;
1167
+ this . passThruBackend = {
1168
+ handle : function ( req ) { return xhrBackend_1 . createConnection ( req ) . response ; }
1169
+ } ;
1170
+ }
1171
+ catch ( e ) {
1172
+ e . message = 'Cannot create passThru404 backend; ' + ( e . message || '' ) ;
1173
+ throw e ;
1175
1174
}
1176
1175
} ;
1177
1176
return HttpBackendService ;
@@ -1262,15 +1261,12 @@ var HttpClientBackendService = (function (_super) {
1262
1261
return resOptions$ . map ( function ( opts ) { return new _angular_common_http . HttpResponse ( opts ) ; } ) ;
1263
1262
} ;
1264
1263
HttpClientBackendService . prototype . setPassThruBackend = function ( ) {
1265
- this . passThruBackend = undefined ;
1266
- if ( this . config . passThruUnknownUrl ) {
1267
- try {
1268
- this . passThruBackend = new _angular_common_http . HttpXhrBackend ( this . xhrFactory ) ;
1269
- }
1270
- catch ( ex ) {
1271
- ex . message = 'Cannot create passThru404 backend; ' + ( ex . message || '' ) ;
1272
- throw ex ;
1273
- }
1264
+ try {
1265
+ this . passThruBackend = new _angular_common_http . HttpXhrBackend ( this . xhrFactory ) ;
1266
+ }
1267
+ catch ( ex ) {
1268
+ ex . message = 'Cannot create passThru404 backend; ' + ( ex . message || '' ) ;
1269
+ throw ex ;
1274
1270
}
1275
1271
} ;
1276
1272
return HttpClientBackendService ;
0 commit comments