Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Less: @import url using http instead of https after minification

I am getting this error:

Mixed Content: The page at 'https://theculprit.com/url' was loaded over HTTPS, but requested an insecure font 'http://fonts.gstatic.com/s/opensans/v10/DXI1ORHCpsQm3Vp6mXoaTYnF5uFdDttMLvmWuJdhhgs.ttf'. This request has been blocked; the content must be served over HTTPS.

When I looked through the source to find where the font was being imported via HTTP rather than HTTPS, the only line pertaining to a font import was:

@import url('//fonts.googleapis.com/css?family=Open+Sans:400,700,300,600,800');

Initially I though HTTPS assets loading over HTTP could be my error, but the font is already being imported using the sources protocol. This only happens after the code has been minified.

I'm not very familiar with fonts/css/less, so I'm completely lost. If there is any other info I can give to help out let me know.

like image 246
Aaron Avatar asked Feb 19 '15 22:02

Aaron


People also ask

What is @import rule in less?

The @import directive is used to import the files in the code. It spreads the LESS code over different files and allows to maintain the structure of code easily. You can put the @import statements anywhere in the code. For instance, you can import the file by using @import keyword as @import "file_name. less".

Should I use @import in CSS?

Yes, always use @import and external Cascading Style Sheets in your Website! CSS does NOT need to be compressed, minimized, preprocessed, etc. And CSS download size, or multiple external CSS files using @import is NOT a problem on the Web.

Can you use @import in CSS?

The @import rule allows you to import a style sheet into another style sheet. The @import rule must be at the top of the document (but after any @charset declaration). The @import rule also supports media queries, so you can allow the import to be media-dependent.

What is the correct syntax for importing a stylesheet in CSS?

The @import CSS at-rule is used to import style rules from other stylesheets.


1 Answers

Turns out the minifier I am using automatically turns an import starting with //myurl to http://myurl and that was causing my issue. I added the processImport: false option and now everything is working as intended.

An issue has been opened regarding this behavior on GitHub.

like image 73
Aaron Avatar answered Oct 04 '22 18:10

Aaron