とりあえずjavaScriptでリモートの画像をみたいので調べてると
[https://stackoverflow.com/questions/22097747/how-to-fix-getimagedata-error-the-canvas-has-been-tainted-by-cross-origin-data]
みたいなのを見つけたのです。
この中にある
As others have said you are "tainting" the canvas by loading from a cross origins domain.
https://developer.mozilla.org/en-US/docs/HTML/CORS_Enabled_Image
However, you may be able to prevent this by simply setting:
img.crossOrigin = "Anonymous";
This only works if the remote server sets the following header appropriately:
Access-Control-Allow-Origin "*"
The Dropbox file chooser when using the "direct link" option is a great example of this. I use it on oddprints.com to hoover up images from the remote dropbox image url, into my canvas, and then submit the image data back into my server. All in javascript :)
をやりたいのです。
img.crossOrigin = "Anonymous";
をJavaScriptに書くのは分かったのですが
Access-Control-Allow-Origin "*"
をサーバーのどこに書けばいいのか全く分かりません。
サーバーはubuntu16.04 でapache2で立てていますが、
apache2.confにそれらしきものは見当たりません
どこに書けばいいのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。