A project uses the Canvas label of Html5. The image displayed by canvas comes from the subdomain of api.xx.com. the domain of the current page is m.xx.com. once it is called through JS: canvas. toDataURL () will report the cross-origin issue: Redirectatorigin & #039; api. xx. c... A project uses the Canvas label of Html5. The image displayed by canvas comes from the subdomain of api.xx.com. the domain of the current page is m.xx.com. once it is called through JS: canvas. toDataURL () will report Cross-origin issues:
Redirect at origin 'http: // api.xx.com '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: // m.xx.com 'is therefore not allowed access.
Is there any related solution for upyun, or can I add Access-Control-Allow-Origin open Control for the header of the cross-Origin request for images?
How can I add Access-Control-Allow-Origin to the request Image header?
Reply content:
A project uses the Canvas label of Html5. The image displayed by canvas comes from the subdomain of api.xx.com. the domain of the current page is m.xx.com. once it is called through JS: canvas. toDataURL () will report Cross-origin issues:
Redirect at origin 'http: // api.xx.com '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: // m.xx.com 'is therefore not allowed access.
Is there any related solution for upyun, or can I add Access-Control-Allow-Origin open Control for the header of the cross-Origin request for images?
How can I add Access-Control-Allow-Origin to the request Image header?
I have encountered this problem before, because the images used are not on the same server.
At that time, the solution was to get the image file content through the server and then output the content on the html page. in this way, the cross-domain problem of images can be solved. (But it may not be correct !)
Addimg.crossOrigin = "Anonymous"
Access-Control-Allow-Origin
This is sent from the background.
I have encountered this problem before, but I didn't handle it like this. for some other reasons, I have to give up obtaining images from the server and change it to a local one.