fix issue with ssr

This commit is contained in:
Giuseppe Digilio
2021-07-08 17:06:02 +02:00
parent 9607a5248b
commit 2bd68b0585

View File

@@ -1,9 +1,9 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { CookieService } from '../services/cookie.service'; import { CookieService } from '../services/cookie.service';
/** /**
@@ -16,15 +16,15 @@ export class LogInterceptor implements HttpInterceptor {
constructor(private cookieService: CookieService, private router: Router) {} constructor(private cookieService: CookieService, private router: Router) {}
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> { intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// Get Unique id of the user from the cookies // Get Unique id of the user from the cookies
const correlationId = this.cookieService.get('CORRELATION-ID'); const correlationId = this.cookieService.get('CORRELATION-ID');
// Add headers from the intercepted request // Add headers from the intercepted request
let headers = request.headers; let headers = request.headers;
headers = headers.set('X-CORRELATION-ID', correlationId); headers = headers.append('X-CORRELATION-ID', correlationId);
headers = headers.set('X-REFERRER', this.router.url); headers = headers.append('X-REFERRER', this.router.url);
// Add new headers to the intercepted request // Add new headers to the intercepted request
request = request.clone({ withCredentials: true, headers: headers }); request = request.clone({ withCredentials: true, headers: headers });