Skip to content

Angular 18.2.x: Strict csp not working when we have aot false and script-src 'self' 'nonce-XYZABC'; #62045

Closed as not planned
@sushil-car

Description

@sushil-car

Command

run

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

With aot false and script-src 'self' 'nonce-XYZABC'; we are getting below error in browser console

EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'nonce-XYZABC". at below line in compilee.mjs file
const fn = _global['eval'](trustedScriptFromString(body));

eval getting blocked by strict CSP.

Is there any fix or to support strict csp with aot false ??

Minimal Reproduction

NA

Exception or Error

EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'nonce-XYZABC".

Error is at below line in compiler.mjs file eval getting blocked by strict CSP

const fn = global['eval'](trustedScriptFromString(body)) as Function;

Your Environment

NA

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions