When the HTML code is rendered in a web browser, the CSS styles are not being

I am utilizing adminer within a docker container.

When testing services, I utilize the URL mydomain.tld. In order to interact with this container directly, one option is to expose and map a port, such as mapping port 8081 to the adminer port 8080.

Accessing this container directly via http://mydomain.tld:8081 functions smoothly without any issues, everything appears to be in order and the Login dialog displays as follows:

https://i.sstatic.net/WmLHm.png

Although, this method exposes user credentials, thus it is not recommended.

However, when trying to access the same docker container via https, I encounter a faulty page. The container is accessed through the address https://mydomain.tld/adm, which is then redirected by the web server from mydomain.tld at port 443 to the adminer container to handle the request. The process seems straightforward. The result mirrors that of the previous approach. So why doesn't it work?

Initially, I used nginx as a proxy and connectivity to the adminer container was successful. Now, I have switched to using yaws and intercepted the call to the adminer container.

https://i.sstatic.net/xpk46.png

Evidently, the js and css files are not being applied by browsers like Opera, Chrome, UR, Vivaldi, Edge, or Firefox, despite the fact that the source code is correct and valid. No browser shows errors in the console except for Firefox (error messages translated by Bing, emphasis added), however, these errors seem to be misattributed:

The Stylesheet did not load due to an incorrect MIME type, text/html instead of text/css.

The script file loaded even though its MIME type (text/html) does not align with accepted types for JavaScript.

These error messages do not accurately reflect reality, as detailed in the source code: The MIME type is clearly text/css, the relation is stylesheet, and the script should be identified as Javascript.

<link rel="stylesheet" type="text/css" href="?file=default.css&amp;version=4.8.1">
<script src='?file=functions.js&amp;version=4.8.1' nonce="ZDA0ODE4Y2ZhZWY1NzkyZTUxNzg3MGZlNTdlNTcxM2M="></script>

Why is Firefox interpreting them as text/html (and presumably other browsers are doing the same)?

It is evident that the URLs utilizing GET variables may not appear conventional, but they should still function properly, as evidenced by various methods:

  1. As stated earlier, the identical code works seamlessly when the container is accessed via http on port 8081.

  2. Clicking on these links within the HTML source in the https version successfully loads the files across all browsers.

  3. Even network analysis via developer tools confirms HTTP status code 200 for all resources, including in Firefox.

This demonstrates that the code delivered to the browser is indeed correct, indicating no issues here. Regardless, the source codes remain indistinguishable, save for the path.

I also tried manipulating the output stream of the adminer container to include the full path, but as predicted, this alteration had no effect, as demonstrated in the following scenario:

Insert the source code of either output in a local document. Since the browser cannot adjust the references, we manually input the full path. By toggling the path FULL_PATH between the http and https versions, I replicated the behavior locally:

<link rel="stylesheet" type="text/css" href="FULL_PATH?file=default.css&amp;version=4.8.1"> 
<!-- http://mydomain.tld:8081/ works; https://mydomain.tld/adm/ works per click, but not in browser--> 

This file isn't even linked via https, since it originates from a local file; only one link is.

Why aren't the browsers rendering these files in the https instance as one would expect, despite developer tools signifying all is well? What could be causing this issue? Is there perhaps a hidden setting inhibiting the rendering of these files over https?

What steps can I take to perform more insightful debugging to identify the cause and solution? At present, I'm running low on ideas.

Refer to yaws crashes with httpc:request for URL served by docker container for details on how the html content is generated.

Answer №1

What is causing Firefox to interpret these files as text/html?

If you check the developer tools' "Network" tab, you will likely find that these files are being served with a Content-type: text/html HTTP response header. This causes the browser to treat them as HTML rather than CSS and Javascript.

According to the Yaws documentation, it appears that your out_adm function needs to return

{content, "text/css", Content}
or
{content, "text/javascript", Content}
[{header, {content_type, "text/javascript"}}, {html, Html}]
(as per Steve Vinoski's comment) instead of {http, Content} in order to respond with the correct header.

Answer №2

Ultimately, the unnecessary workaround proved ineffective and the answer was simple: implement Yaws with revproxy = / http://adm:8080 in the configuration file yaws.conf, utilizing a new server directive like abc.mydomain.tld.

Despite this, valuable lessons were gained. Sincere thanks to both parties for their dedication.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble with ion-item click not functioning in Ionic 3?

Working on my Ionic 3 project, I have encountered an issue with the ion-item click listener. The scenario is that I am adding text over a canvas and then attempting to change the style of the text (such as font-family, font-size, bold, and italic). The UI ...

Tips for improving the styling of a django form with mixed elements

Here are two different forms I am working with: class InitialForm(Form): trn = IntegerField(widget=NumberInput, required = False) klient = ChoiceField(choices=KLIENTS, required = False) class SecondForm(Form): faktura = CharField(max_length = ...

unrestricted motion through the utilization of css3 transitions and translations

When applying a new CSS translate, it's common practice to specify the exact number of pixels you want an element to move, such as 50px, 60px. This results in a relative movement from its current position. You can see an example of this here: http://j ...

Having trouble accessing listview capabilities in jquerymobile?

I am currently delving into the world of jquerymobile. I am experimenting with a sample project where I aim to showcase a listview. Below is the code that I have been working on. <!doctype html> <html> <head> <link rel="stylesheet" h ...

CSS Navigation Bar Fails to Function Properly on Mobile Devices

Check out the plunkr I have created by visiting: http://plnkr.co/edit/gqtFoQ4x2ONnn1BfRmI9?p=preview The menu on this plunkr functions correctly on a desktop or laptop, but it doesn't display properly on a mobile device. I suspect that the issue may ...

Angular 2's Multi-select dropdown feature allows users to select multiple options

Recently, I encountered an issue with customizing CSS for angular2-multiselect-dropdown. I found the solution in this link: https://www.npmjs.com/package/angular2-multiselect-dropdown. I have included my code below. Any assistance in resolving this matter ...

Ways to conceal the label without using JavaScript when focusing

I am trying to find a way to hide the label "phone number" when the input is in focus by simply clicking on it. I have attempted using CSS but I need a more effective solution. Please let me know if you can help. <div class="form-row"> ...

Is it possible to maintain the sidebar while eliminating the scrolling JavaScript?

Looking to recreate the image display style on Facebook where pictures appear in a lightbox format. The challenge I'm facing is figuring out how they manage to have the sidebar with no visible scroll bar inside... If you want to see this for yourself ...

Encountering the error "AxiosError: connect ECONNREFUSED" while making a python API call in a nodejs environment

When attempting to call an API in my Python script from a Node.js script, I encountered the error "AxiosError: connect ECONNREFUSED." The Flask app is running on localhost:5000 and the Node app on localhost:5005, but for some reason, the connection is bein ...

Javascript functions properly on Chrome, Opera, and Edge browsers, but unfortunately does not work on FireFox and IE 11

If you're interested, I have some code available on JS Fiddle that showcases my skills. var getJSON = function (url) { "use strict"; return new Promise(function(resolve, reject) { var xhr = new XMLHttpRequest(); xhr.open('get' ...

What causes custom CSS properties to be overridden by Material UI CSS class properties?

I encountered an issue while attempting to utilize an npm package containing a Typography element from Material UI. The code is authored by me. Upon integrating it into a project, I noticed that the typography's CSS class properties were overpowering ...

Can you explain the significance of the characters '& > * + *' in JSX (CSS)?

When using material UI, the progressbar demo includes lines of JSX code like this: '& > * + *': { marginTop: theme.spacing(2), }, Can you explain what the selector '& > * + *' represents in this context? ...

HTML does not support the use of certain symbols

Currently, I am in the process of designing a homepage for my school project. However, I have run into an issue. The content that I want to be displayed on my homepage is as follows: "Daudzspēlētāju tiešsaites lomu spēle (Massively Multiplayer Online ...

Creating an Eye-catching Presentation: Tips for Adding Text to Your CSS3 Slideshow

I am currently in the process of creating a CSS3 slideshow with text for each image. I found inspiration from this example: . However, I made some modifications to make it responsive. Here is the HTML code I have used: <div id="slideshow"> < ...

Is it possible to convert an image into text using CSS just for the purpose of printing

Imagine having a prominent banner at the top of a webpage that you want to print. Instead of depleting someone's ink by printing the entire banner image, is it possible to utilize CSS to substitute the image with text in H1 size? ...

Creating a search form in Bootstrap 4 that is centered and expands to full width only on small screens

I'm currently working with a bootstrap v.4 navbar that has 3 elements in it. I've managed to align the elements evenly so that the search bar is centered in the navbar. However, when it collapses it takes up the full width of the screen. Here is ...

Enhancing user experience with dynamically resized Jumbotron images based on screen sizes in HTML

I am experiencing an issue with the jumbotron images on my website where they become increasingly zoomed in as the screen size decreases, and are extremely zoomed in on mobile devices. Is this a normal behavior of jumbotrons? I do understand that the image ...

Is it possible to access the CSS property from an external CSS file even when inline styles are used?

Is there a way to retrieve the css property from an external source using JavaScript or jQuery even if inline styles are applied to the same element? Here's an example: <div id="my" style='left:100px'>some content</div> <styl ...

Is there a way to position my input at the bottom of its parent element?

Is there a way to position this input element at the bottom and center of its parent div? https://i.sstatic.net/gs1yP.jpg ...

I created some jQuery code that modifies a button when it is hovered over, however, I ended up writing the code individually for each button. What steps can I take to turn it

Is there a way to turn the code for each button on my website into a jQuery function that can be applied to any button? This is how the code currently appears: $(document).ready(function() { $("#linkXML").hover( function() { ...