ymakux
ymakux

Reputation: 3485

Unable to load bootstrap icons on http://

"Font from origin 'http://www.example.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.com' is therefore not allowed access."

Getting this error when page delivered from http://example.com. http://www.example.com works fine. All bootstrap's files stored locally. Is this a server bug?

UPD This is how files are included

<link href="catalog/view/css/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="catalog/view/javascript/jquery/jquery-1.11.3.min.js"></script>
    <script src="catalog/view/javascript/jquery/jquery-ui-1.11.4-autocomplete/jquery-ui.min.js"></script>
    <script src="catalog/view/css/bootstrap/js/bootstrap.min.js"></script>
    <script src="catalog/view/theme/js/common.js"></script>

UPD: solved by changing base domain in the <base> metatag

<base href="http://example.com"/>

Upvotes: 0

Views: 398

Answers (1)

Quentin
Quentin

Reputation: 943143

No. www.example.com and example.com are different origins — even if you host the same website on each of them.

  • Avoid using absolute URIs in your code
  • Pick one of the two hostnames to be canonical and configure the other one to redirect to it.

Upvotes: 3

Related Questions