I have registered to Microsoft Azure cloud storage services and quickly got lost from the complex plethora of virtualization services which are 100% irrelevant for me because I am not a professional server administrator and all I want to do there is just to store a store a CSS file to access it from this JavaScript file.
How to store CSS/JS asset files on a cloud which is not a website hosting per se (Azure Storage in my case)?
You might think this is strange and even silly but in Windows 11 Home desktop folder I have these two files for fast developments:
js.js
css.css
JS files donât recognize the desktop folder as a folder from my tries and I donât want to put the files in a non-desktop folder in Windows 11 Home, so I want to keep the CSS file on a cloud and rain it down via a URL.
That said
Maybe I do need to change attitude and put the files on a regular folder in my Windows 11 Home and create file shortcuts and put them in the desktop folder, but Microsoft made the process of making file shortcuts longer in Windows 11 Home with the âShow more optionsâ button and the longer list it brings and I donât like to cooperate with that, hence the allegedly strange and absurd situation we discuss.
I donât really understand your windows complaints. Thereâs nothing different about a folder on the desktop vs one not on the desktop. Browsers may restrict loading an asset via a file:// url if that is what you are trying to do. If you use a relative path though, it should work just fine.
That said, the best way to do local development is to install a webserver locally and load your code via the http://localhost url. If all you want is a web server, you can install Apache from Apache Lounge. If you want a more complete setup with mysql, php, etc you can try the various bundle installers like Laragon, xampp, or wamp.
As for azure storage, you have to first create a storage account. After you create the account, you can open it and on the side menu find and click the Static Website option. Toggle the option to enable static website hosting and it will show you the URL for your site. Finally, on the side menu click the Containers option and open the $web container and upload your files there.
This is a good approach; I have actually tried to install WAMP to run two Media-Wiki websites currently hosted on shared hosting but no longer have SSL certificates a few days ago and got many errors about missing Microsoft Redistributable packages but I didnât want to start pick and download them at the time and I thought about an online solution like CertSage.
Perhaps I should try XAMPP or something else, as user:kicen suggested below.
My mistake, the error I got each time whether if the files were inside the desktop folder or a regular folder, is:
Refused to apply style from âhttps://example.com/css.cssâ because its MIME type (âtext/htmlâ) is not a supported stylesheet MIME type, and strict MIME checking is enabled.
But I think that my more fundamental mistake is that I canât even target a CSS file as a Windows file in the following pattern or similar:
cssElement.setAttribute("href", "css.css");
Therefore, I should probably put the file over localhost with one of the programs you have suggested.
Azure
I didnât find the Static Website option in the sidebar but under âAll Servicesâ (thatâs a heck of a long cluster of services):
I am probably missing something there but anyway I think that for my specific task here Azure might be an overkill (although Iâll still be happy to learn what I am probably missing).
Enable the static website website feature and it will generate a URL for you to use which will serve the contents of a special $web container that will be automatically created. To upload your file, find Containers on the side menu for the storage account, open the $web container and click the Upload button at the top.
An all default âstatic websiteâ in Azure had a deployment error but I had no desire to debug it because I find Azure unjustly cumbersome or complicated.
I have installed XAMPP and from navigating to localhost in a web browser I figure that it works just fine, but I still have a problem loading the CSS file:
Refused to apply style from âhttps://example.com/localhost/css.cssâ because its MIME type (âtext/htmlâ) is not a supported stylesheet MIME type, and strict MIME checking is enabled.
But after adding http:// before localhost just as you have shown, I did get the file loaded successfully.
I am surprised that when it is localhost there isnât a fallback from TLS-HTTPS (port 443) to HTTP (port 80).
Perhaps it will become a standard to have such a fallback in the future.
This is a relative path and will be appended to the current path when resolved. The fact that localhost is also a hostname is neither here nor there. It remains a relative path URL.
If you want to make sure to use localhost as host either put https://localhost or ://localhost at the start.