CORS 策略阻止的字体文件

Fonts files blocked by CORS policy

我正在 Windows Server 2016 上部署我的网站,使用 Apache24 来提供静态文件。它们都很好(js、css、图像)但是字体文件。

通过互联网阅读后,我将其添加到 httpd.conf 文件中:

<IfModule headers_module>
  <FilesMatch "\.(ttf|otf|eot|woff|woff2|font.css|css|js)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

并取消注释行:

LoadModule headers_module modules/mod_headers.so

但我仍然收到此错误,其中 server_ip 是真实的服务器 ip 地址

Access to Font at 'http://server_ip/static/control/fonts/glyphicons-halflings-regular.woff2' from origin 'http://server_ip:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://server_ip:8080' is therefore not allowed access.

这是与使用 ip 地址而不是域有关的问题吗??我还在等域,所以我必须指向 ip。

我是不是在 apache 配置中遗漏了什么?因为我还加了

<IfModule mime_module>
  AddType application/x-font-ttf .ttc .ttf
  AddType application/opentype .otf
  ...
</IfModule>
...
<IfModule rewrite_module>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>

没有结果。

如有任何帮助,我们将不胜感激。 谢谢。

是浏览器的问题。

我意识到需要安装 Chrome 插件 Allow-Control-Allow-Origin: *