Skip to content

Commit 7bb51b7

Browse files
committed
update _host file as workaround for Angular bug in 18.2.7
1 parent 54ec108 commit 7bb51b7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

bff/server/Pages/_Host.cshtml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,16 @@
2626
// The nonce is passed to the client through the HTML to avoid sync issues between tabs
2727
source = source.Replace("**PLACEHOLDER_NONCE_SERVER**", nonce);
2828

29-
var nonceScript = $"<script nonce=\"{nonce}\" src=";
30-
source = source.Replace("<script src=", nonceScript);
29+
if (hostEnvironment.IsDevelopment())
30+
{
31+
// do nothing in development, Angular > 18.1.0 adds the nonce automatically
32+
}
33+
else
34+
{
35+
// Angular release build does not add any nonce to the scripts, so we need to add it manually
36+
var nonceScript = $"<script nonce=\"{nonce}\" ";
37+
source = source.Replace("<script ", nonceScript);
38+
}
3139

3240
// link rel="stylesheet"
3341
var nonceLinkStyle = $"<link nonce=\"{nonce}\" rel=\"stylesheet\" ";

0 commit comments

Comments
 (0)