Page 1 of 1

Issue with CSS link in version 27.0.0.1

Posted: Tue Jan 07, 2025 6:40 pm
by aujunior
We are using Oxygen Web version 25.1.0.1 and have started testing our framework on version 27.0.0.1.

We chose to download the All Platforms version since the .war version is no longer available. Additionally, we updated the framework SDK via Maven to version 27.

However, we noticed that the CSS is no longer loading correctly in this new version. We are receiving a MIME type error, even though no code changes were made. The only modifications were updating the SDK and the Web platform version.

I need assistance to restore normal functionality. Could you please help us?

Error:
image.png
Created link:
image.png
Code:

Re: Issue with CSS link in version 27.0.0.1

Posted: Tue Jan 07, 2025 10:11 pm
by aujunior
Hello,

I noticed that something is unexpectedly altering the MIME type.

Even when sending the <link rel="stylesheet"> element with the attribute type="text/css", the system indicated that the MIME type was set to application/json.

I haven’t been able to identify the cause of this alteration yet, but I noticed that this issue does not occur when using Oxygen Web 25.

Re: Issue with CSS link in version 27.0.0.1

Posted: Wed Jan 08, 2025 7:28 pm
by Bogdan Dumitru
Hello,

There was a security improvement that causes this.
You have to modify the way you load the CSS files, more precisely the "appendHeadCss" function. Instead of <link rel="stylesheet" type="text/css" href="..."> you have to create an "<script>" element and put the CSS inside. It should look somewhat like this:

Code: Select all

function loadCSSFile (fileRef) {
  fetch(fileRef)
    .then(response => {
      if (!response.ok) {
        throw new Error('Network response was not ok');
      }
      return response.text();
    })
    .then(cssContent => {
      var styleTag = document.createElement('style');
      styleTag.type = 'text/css';
      if (styleTag.styleSheet) {
        styleTag.styleSheet.cssText = cssContent; // For IE
      } else {
        styleTag.appendChild(document.createTextNode(cssContent)); // For other browsers
      }
      document.head.appendChild(styleTag);
    })
    .catch(error => {
      console.error('Error loading CSS file:', error);
    });
};

Re: Issue with CSS link in version 27.0.0.1

Posted: Wed Jan 08, 2025 7:31 pm
by Bogdan Dumitru
By the way, the next version of Web Author 27.1 has another security feature enabled by default, CSP Policy, and this may break loading CSS that way. So keep in mind that in the next version you may have to disable CSP Policy from the Administration page.

Re: Issue with CSS link in version 27.0.0.1

Posted: Wed Jan 08, 2025 9:51 pm
by aujunior
Thank you very much, Bogdan Dumitru, for your responde!

I applied the correction you suggested, and now the CSS is loading properly. I've also noted your recommendation about CSP Policy to avoid opening future tickets. :lol: