Avatar of Bruce Gust
Bruce Gust
Flag for United States of America asked on

My CSS files are being blocked by a CORS policy. How do I fix that?

Here's my homepage (http://new.brucegust.com/):



If I go to the "Dashboard" (after you login):


I lose my pink header as well as some styling. 


When you pop the hood, you see this error:


Access to CSS stylesheet at 'http://nomas.site/assets/bodybg/bg1.css' from origin 'http://new.brucegust.com' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`.
nomas.site/assets/bodybg/bg1.css:1 Failed to load resource: net::ERR_FAILED
home:1 Access to CSS stylesheet at 'http://nomas.site/assets/color/pink.css' from origin 'http://new.brucegust.com' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`. nomas.site/assets/color/pink.css:1 Failed to load resource: net::ERR_FAILED home:1 Access to CSS stylesheet at 'http://nomas.site/assets/bodybg/bg1.css' from origin 'http://new.brucegust.com' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`. home:1 Access to CSS stylesheet at 'http://nomas.site/assets/color/pink.css' from origin 'http://new.brucegust.com' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`.

Open in new window

So, for some reason, some of my CSS files are being blocked by a CORS policy. 


What is that, why does it not show up on other pages and how do I fix it?


Thanks!

LaravelPHPCSS

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Dave Baldwin

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
David Favor

This is correct behavior.

You're referencing files as https:// protocol, rather than https:// so CORS will fail.

The fix...

Change all URLs to //path-to-file, so no http:// + no https:// + no host/domain name.

If you use this policy, then your CORS problems will disappear + also site migration (changing host/domain name) will be trivial.
SOLUTION
Julian Hansen

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck