import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; import { inject, Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { getConfig } from './iqser-config.service'; import { BASE_HREF } from '../utils'; @Injectable() export class ApiPathInterceptor implements HttpInterceptor { readonly #config = getConfig(); readonly #baseHref = inject(BASE_HREF); intercept(req: HttpRequest, next: HttpHandler): Observable> { if (!req.url.startsWith('/assets')) { const apiUrl = `${this.#config.API_URL}${req.url}`; return next.handle(req.clone({ url: apiUrl })); } const url = this.#baseHref + req.url; return next.handle(req.clone({ url })); } }