mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
fix issue with ssr
This commit is contained in:
@@ -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 });
|
||||||
|
Reference in New Issue
Block a user