After a B2C page layout version upgrade, the script tag for unified.min.js is not properly formatted when the page loads. Instead of closing correctly, the script tag appears as follows:
This results in a malformed tag with an extra , causing unexpected behavior.
To Reproduce
Steps to reproduce the behavior:
Run the commands: npm run build followed by npm run server to start the application.
Once the application is up and running, navigate to any page where the unified.min.js script should load.
Open the browser developer tools (right-click on the page and select "Inspect").
In the "Network" tab, check the script loading section, and we will observe a malformed script tag, as shown in the screenshots.
Instead of loading properly, the script contains an extra closing tag (</script>), resulting in the following:
Describe the bug
After a B2C page layout version upgrade, the script tag for unified.min.js is not properly formatted when the page loads. Instead of closing correctly, the script tag appears as follows:
https://sampledomain/static/content/js/stage-2/unified.min.js?v=1728718798338></script>
This results in a malformed tag with an extra , causing unexpected behavior.
To Reproduce
Steps to reproduce the behavior:
Run the commands: npm run build followed by npm run server to start the application. Once the application is up and running, navigate to any page where the unified.min.js script should load. Open the browser developer tools (right-click on the page and select "Inspect"). In the "Network" tab, check the script loading section, and we will observe a malformed script tag, as shown in the screenshots.
Instead of loading properly, the script contains an extra closing tag (</script>), resulting in the following:
Expected behavior
The script tag should load and close correctly without extra tags. Expected output: https://sampledomain/static/content/js/stage-2/unified.min.js?v=1728718798338>
Screenshots
1) After B2C Page Layout Version Upgrade:
2) Working Screenshot (Older Version):
Desktop (please complete the following information):
Additional context
We've tried the following approaches to resolve the issue, but the problem persists:
existing ::
1. Webpack Configuration (HtmlWebpackPlugin): new HtmlWebpackPlugin({ filename: '../../../stage-2/unified.html', template: path.resolve(__dirname, 'src/stage-2/unified.html'), chunks: ['stage-2/unified.min'], publicPath: '/static/content/js/', inject: 'body' }),
2) Content-Security-Policy (CSP) Headers
res.setHeader('Content-Security-Policy', "default-src 'none'; script-src 'self' 'unsafe-inline'; connect-src 'self'; font-src 'self'; img-src 'self'; style-src 'self';base-uri 'self';form-action 'self'");
3. Unified.html: Moved the script tags to the section as recommended here.
https://learn.microsoft.com/en-us/azure/active-directory-b2c/javascript-and-page-layout?pivots=b2c-user-flow
Existing Unified.html code ::
Updated Webpack Configuration (HtmlWebpackPlugin):
new HtmlWebpackPlugin({ filename: '../../../stage-2/unified.html', template: path.resolve(__dirname, 'src/stage-2/unified.html'), chunks: ['stage-2/unified.min'], publicPath: '/static/content/js/', inject: 'body', xhtml: false, // Ensures self-closing tags like are properly formatted minify: false, templateParameters: { correlationId: process.env.CORRELATION_ID || 'defaultCorrelationId', // Pass correlationId }, }),
Updated CSP Headers: res.setHeader('Content-Security-Policy', "default-src 'none'; " + "script-src 'self'; " + // Removed 'unsafe-inline' for better security "connect-src 'self'; " + "font-src 'self'; " + "img-src 'self'; " + "style-src 'self' 'unsafe-inline'; " + "base-uri 'self'; " + "form-action 'self'; " + "frame-ancestors 'none'; " + "report-uri /csp-violation-report-endpoint;" );
Despite these adjustments, the issue remains unresolved, and the script tag still appears malformed