import { Injectable } from '@angular/core';
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
import { Observable } from 'rxjs';

@Injectable()
export class TokenInterceptor implements HttpInterceptor {

  intercept(
    request: HttpRequest<unknown>,
    next: HttpHandler
  ): Observable<HttpEvent<unknown>> {
    console.log('TokenInterceptor: RAW request URL:', request.url);
    // console.log('TokenInterceptor: Headers *before* next.handle (cookie attached automatically by browser):',
    //   request.headers.keys().map(k => `${k}: ${request.headers.get(k)}`));
    return next.handle(request);
  }
}
