Skip to content

Commit

Permalink
fix(api): merge contextual headers
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Feb 3, 2025
1 parent 65dfbde commit 358335a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/app/Shared/Services/Api.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1534,13 +1534,18 @@ export class ApiService {
const req = () =>
combineLatest([
this.ctx.url(`${p}${params ? '?' + params : ''}`),
this.ctx.headers((config || {}).headers).pipe(
this.ctx.headers(config?.headers).pipe(
map((headers) => {
let cfg = config;
if (!cfg) {
cfg = {};
const cfg = config || {};
if (!cfg.headers) {
cfg.headers = new Headers();
}
cfg.headers = headers;
const mergedHeaders = new Headers();
[headers, cfg.headers].forEach((source) => {
const h = new Headers(source);
h.forEach((v, k) => mergedHeaders.set(k, v));
});
cfg.headers = mergedHeaders;
return cfg;
}),
),
Expand Down

0 comments on commit 358335a

Please sign in to comment.