Browser does not load CSS with "Access-Control-Allow-Origin: *"

I am trying to load CSS and Javascript file from cross origin. I also set the header Access-Control-Allow-Origin: *

in the response, but the browser does not download the files, I download the CSS using the code below:

var fileref = document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", filename);
document.getElementsByTagName("head")[0].appendChild(fileref);

      

I want to download css and js using a http connection to be uploaded to https: // [site]

+3


source to share


1 answer


Make sure the variable filename

has the correct path with http://

as part of it. Example: http://localhost:8080/css/style.css

orhttp://localhost:8080/project_folder/css/style.css



0


source







All Articles