Access-Control-Allow-Origin headers not working

早过忘川 提交于 2020-01-14 12:49:26

问题


Even though I've added this in my .htaccess file:

Header add Access-Control-Allow-Origin "*"

And this in my apache config: (Inside a section AND outside)

<Files ~ "\.(gif|jpe?g|png|js|json|xml)$">
        Header set Access-Control-Allow-Origin "*"
</Files>

It still does not work!

When I get the DIRECTORY it does give me the wanted header, but as soon as I download a specific file the header is nowhere to be found!

How hard can it be?


回答1:


try

<FilesMatch "\.(gif|jpe?g|png|js|json|xml)$">
  <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
  </IfModule>
</FilesMatch>


来源:https://stackoverflow.com/questions/6329655/access-control-allow-origin-headers-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!