Skip to content

Commit

Permalink
test 18.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Oct 6, 2024
1 parent 68c0667 commit c758083
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions server/Pages/_Host.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,16 @@
// The nonce is passed to the client through the HTML to avoid sync issues between tabs
source = source.Replace("**PLACEHOLDER_NONCE_SERVER**", nonce);

var nonceScript = $"<script nonce=\"{nonce}\" ";
source = source.Replace("<script ", nonceScript);
if (hostEnvironment.IsDevelopment())
{
// do nothing in development, Angular > 18.1.0 adds the nonce automatically
}
else
{
// Angular release build does not add any nonce to the scripts, so we need to add it manually
var nonceScript = $"<script nonce=\"{nonce}\" ";
source = source.Replace("<script ", nonceScript);
}

// link rel="stylesheet"
var nonceLinkStyle = $"<link nonce=\"{nonce}\" rel=\"stylesheet";
Expand Down

0 comments on commit c758083

Please sign in to comment.