Set custom header for the request made from

后端 未结 4 1645
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 10:22

Let\'s say I have a code like this:


How to configure custom headers for thi

4条回答
  •  没有蜡笔的小新
    2020-12-03 10:28

    You cannot change the browser's HTTP request for resources loaded by the tag. Whatever you are trying to do, you will need to find an alternative approach.

    For example, you could proxy the request through your own server and modify the headers there. Or you could parametrise the URL of the resource with a query string.

    As Alex points out, you may also be able to use an XmlHTTPRequest object to load the image data and use the setRequestHeader function, though I suspect you are limited in what headers you can set (I doubt you can spoof the referrer or user agent for example, though I haven't tested this).

提交回复
热议问题