我正在使用Electron和Angular 7创建一个应用程序:
我正在使用HttpInterceptor为来自应用程序的每个HTTP请求添加authToken。 但是我也想为每个HTTP请求添加一个客户端证书。可以使用角度或电子吗?
import { Injectable } from '@angular/core';
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from
'@angular/common/http';
import { Observable } from 'rxjs';
import { AuthenticationService } from '../_services';
@Injectable()
export class JwtInterceptor implements HttpInterceptor {
constructor(private authenticationService: AuthenticationService) { }
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// add authorization header with jwt token if available
let currentUser = this.authenticationService.currentUserValue;
if (currentUser && currentUser.token) {
request = request.clone({
setHeaders: {
Authorization: `Bearer ${currentUser.token}`
}
});
}
return next.handle(request);
}
}
我可以在标题中添加证书和密钥吗?