Google字体无法正常显示错误"请求资源上存在"否'Access-Control-Allow-Origin'标头"

Dan*_*aka 1 fonts google-font-api

对不起伙计,这可能是重复但我还没有找到解决方案

我一直在为我的所有项目使用Google字体.最近,有一些奇怪的事情发生,字体没有加载,当我检查控制台时,我发现这个错误

Font from origin 'http://fonts.gstatic.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://localhost' is therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)

我已经在线检查并在stackoverflow上阅读了一些有关此事的答案,但未能找到解决方案.谷歌字体发生了什么,有没有办法解决这个问题?我想找一个简单而有效的解决方案,请帮忙.

Pra*_*ase 6

htaccess文件中进行如下更改,以便您可以访问

 <FilesMatch "\.(ttf|otf|eot|woff)$">
      <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
      </IfModule>
    </FilesMatch>
Run Code Online (Sandbox Code Playgroud)