1
|
import {Injectable} from '@angular/core';
|
2
|
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';
|
3
|
import {Observable} from 'rxjs';
|
4
|
|
5
|
/**
|
6
|
* Adds authentication token to each request.
|
7
|
*/
|
8
|
@Injectable()
|
9
|
export class BasicAuthInterceptor implements HttpInterceptor {
|
10
|
constructor() {
|
11
|
}
|
12
|
|
13
|
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
14
|
request = request.clone({
|
15
|
withCredentials: true,
|
16
|
});
|
17
|
|
18
|
return next.handle(request);
|
19
|
}
|
20
|
}
|