From 5d9b56389644a0df028f9d2da54d0853f3f19b23 Mon Sep 17 00:00:00 2001 From: Aaron Shim Date: Mon, 21 Oct 2024 21:41:28 +0000 Subject: [PATCH] Try throwing an error if SSR and auto-CSP are both set at the same time! --- .../build/src/utils/index-file/index-html-generator.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/angular/build/src/utils/index-file/index-html-generator.ts b/packages/angular/build/src/utils/index-file/index-html-generator.ts index b88074deee12..9bfb929c5d11 100644 --- a/packages/angular/build/src/utils/index-file/index-html-generator.ts +++ b/packages/angular/build/src/utils/index-file/index-html-generator.ts @@ -12,11 +12,11 @@ import { NormalizedCachedOptions } from '../normalize-cache'; import { NormalizedOptimizationOptions } from '../normalize-optimization'; import { addEventDispatchContract } from './add-event-dispatch-contract'; import { CrossOriginValue, Entrypoint, FileInfo, augmentIndexHtml } from './augment-index-html'; +import { autoCsp } from './auto-csp'; import { InlineCriticalCssProcessor } from './inline-critical-css'; import { InlineFontsProcessor } from './inline-fonts'; import { addNgcmAttribute } from './ngcm-attribute'; import { addNonce } from './nonce'; -import { autoCsp } from './auto-csp'; type IndexHtmlGeneratorPlugin = ( html: string, @@ -95,6 +95,9 @@ export class IndexHtmlGenerator { // Auto-CSP (as the last step) if (options.autoCsp) { + if (options.generateDedicatedSSRContent) { + throw new Error('Cannot set both SSR and auto-CSP at the same time.'); + } this.csrPlugins.push(autoCspPlugin(options.autoCsp.unsafeEval)); } }