I've written an angular interceptor to add some headers to my requests. Everything's fine till the SSE request, it is not intercepted !
@Injectable()
export class SessionUserDataInterceptor implements HttpInterceptor {
constructor(@Inject(SESSION_USER_DATA) private userData: SessionUserData) {}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const setHeaders = {};
if (this.userData.line) {
setHeaders['Line'] = this.userData.line;
}
if (this.userData.profil) {
setHeaders['Profil'] = this.userData.profil.id;
}
return next.handle(request.clone({setHeaders}));
}
}
SessionUserData is just a wrapper for the SessionStorage.
I've tried to add the headers to my SSE connection but it's not working neither.
const es = new EventSource(url, {headers: {Line: 'XXX', Profil: 'YYY'}} as any);
Any help's appreciated.