Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
fix(@nguniversal/common): correctly handle headers for jsdom in Clover
Browse files Browse the repository at this point in the history
(cherry picked from commit 39e474a)
  • Loading branch information
hiepxanh authored and alan-agius4 committed Jun 7, 2022
1 parent 94fd257 commit baff49b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions modules/common/clover/server/src/custom-resource-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ import { normalize } from 'path';

export class CustomResourceLoader extends ResourceLoader {
constructor(
private readonly baseUrl: string,
readonly headers: Record<string, string | undefined | string[]> | undefined,
private readonly publicPath: string,
private readonly baseUrl: string,
private readonly fileCache: Map<string, Buffer>,
) {
super();
super({
userAgent: headers?.['user-agent'] as string | undefined,
});
}

fetch(url: string, _options: FetchOptions): AbortablePromise<Buffer> | null {
Expand Down
4 changes: 2 additions & 2 deletions modules/common/clover/server/src/server-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ export class Engine {
const inlineCriticalCss = options.inlineCriticalCss !== false;

const customResourceLoader = new CustomResourceLoader(
origin,
options.headers,
options.publicPath,
origin,
this.resourceLoaderCache,
);

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

0 comments on commit baff49b

Please sign in to comment.