English 中文(简体)
为什么没有以交叉来源图像要求发送在 c中参考的图像?
原标题:Why are cookies not sent with cross origin image request for image referenced in css?

当图像在<代码><img> 弧属性时发送的,为什么没有发出交叉面面图像申请。

  • Page is hosted at host1.mydomain.net.
  • Images are hosted at host2.mydomain.net.
  • There are cookies on host2.mydomain.net.

CORS 图像头目:

    <style>
        #imagemask {
            mask-image: url("https://host2.mydomain.net/images/imagemask.png");
        }
    
    </style>
    
    
    <div id="imagemask"></div>
    <img src="https://host2.mydomain.net/images/image.png" />
  • Both image requests have Sec-Fetch-Site: same-site
  • The request for image.png has Sec-Fetch-Mode: no-cors and sends the cookie.
  • The request for imagemask.png has Sec-Fetch-Mode: cors and does not send the cookie.
问题回答

You can use attribute crossorigin in <img> tag (see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#crossorigin) to enable CORS request that is same as the url() made.

Default <img> tag is non-CORS request, so Sec-Fetch-Mode





相关问题
How to suppress/remove PHP session cookie

I need to suppress an already set session cookie header, but I cannot find any way to do this. Why? I need to make an image, sent by a PHP script, cacheable by the end user; this image is used to ...

Remove Cookies from JS or CSS files

Bizarrely my javascript and css files have cookies (says Firebug). I use Zend Framework and I think it has to do with it. Could I change the .htaccess that CSS or JS files don t link to the ZF or is ...

httplib2, how to set more than one cookie?

As you are probably aware, more often than not, an HTTP server will send more than just a session_id cookie; however, httplib2 handles cookies with a dictionary, like this: response, content = http....

cookies control

what tool wold you recommend me to use in order to see what data are stored in my cookies while i m browsing the net. I m a beginner into webdev field(6 months php experience) and i m curious to see ...

热门标签