我在图像服务器(maptile.org)上创建了一个.htaccess文件。已启用.htaccess中的跨源资源共享不起作用
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header set Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
我能使用a2enmod headers
我测试了一下它与apachectl -M
启用MOD-header和它上市headers_module (shared)
这个建议在这个问题: Header set Access-Control-Allow-Origin in .htaccess doesn't work
然而,当我尝试保存作为图像的地图(使用html2canvas)它给我在控制台中的错误 http://www.justicemap.org/?id=63
错误:当图像存储在justicemap.org域
Image from origin ' http://maptile.org ' 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://www.justicemap.org ' is therefore not allowed access.
另存为图片功能工作。
当我使用html2canvas时,请求方法是“GET”,响应状态码是“200”,并且mimeType是“image/png”。我没有看到Access-Control-Allow-Origin标题。
我是否需要添加Origin标头?我在Chrome Javascript控制台中查看请求时看不到一个。
我使用的CloudFlare的DNS。这会影响到这一点吗?此链接表示Cloudflare支持CORS:https://support.cloudflare.com/hc/en-us/articles/200308847-Does-CloudFlare-support-Cross-origin-resource-sharing-CORS- –