Skip to content

Commit 39e474a

Browse files
hiepxanhalan-agius4
authored andcommitted
fix(@nguniversal/common): correctly handle headers for jsdom in Clover
1 parent 39d7a6a commit 39e474a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

modules/common/clover/server/src/custom-resource-loader.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ import { normalize } from 'path';
1212

1313
export class CustomResourceLoader extends ResourceLoader {
1414
constructor(
15-
private readonly baseUrl: string,
15+
readonly headers: Record<string, string | undefined | string[]> | undefined,
1616
private readonly publicPath: string,
17+
private readonly baseUrl: string,
1718
private readonly fileCache: Map<string, Buffer>,
1819
) {
19-
super();
20+
super({
21+
userAgent: headers?.['user-agent'] as string | undefined,
22+
});
2023
}
2124

2225
fetch(url: string, _options: FetchOptions): AbortablePromise<Buffer> | null {

modules/common/clover/server/src/server-engine.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ export class Engine {
5151
const inlineCriticalCss = options.inlineCriticalCss !== false;
5252

5353
const customResourceLoader = new CustomResourceLoader(
54-
origin,
54+
options.headers,
5555
options.publicPath,
56+
origin,
5657
this.resourceLoaderCache,
5758
);
5859

@@ -76,7 +77,6 @@ export class Engine {
7677
resources: customResourceLoader,
7778
url: options.url,
7879
referrer: options.headers?.referrer as string | undefined,
79-
userAgent: options.headers?.['user-agent'] as string | undefined,
8080
beforeParse: (window) => {
8181
augmentWindowWithStubs(window);
8282
window.ngRenderMode = true;

0 commit comments

Comments
 (0)