Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

启用CDN的时候遇到了跨域问题 #1

Closed
mashirozx opened this issue Dec 9, 2017 · 1 comment
Closed

启用CDN的时候遇到了跨域问题 #1

mashirozx opened this issue Dec 9, 2017 · 1 comment

Comments

@mashirozx
Copy link

就是常见的一个主页域名+一个CDN域名,这时 console 显示:

DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at "https://xxxx.xxxx/textures/default-costume.png" may not be loaded.

就是仅仅贴图一张无法加载。CDN用的是七牛,已经正确配置了域名白名单。仔细看了一下 Mozilla 的文档,发现似乎是对于图片有特别的跨域策略。。。

See:

https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image

https://blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html

参照 Mozilla 的文档,觉得应该是在这里的75行这样添加跨域支持?

var loadedImage = new Image();
loadedImage.setCrossOrigin ( 'anonymous' );
loadedImage.src = path;

JS 萌新甚至连怎么编译都不知道,不知道我的想法正确吗?

@journey-ad
Copy link
Owner

我稍后确认一下

xiazeyu added a commit to xiazeyu/live2d-widget.js that referenced this issue Jan 13, 2018
by the way, we fixed journey-ad/live2d_src#1 and
journey-ad/live2d_src#3 , thanks for your great work!
xiazeyu added a commit to xiazeyu/live2d-widget.js that referenced this issue Jan 13, 2018
by the way, we fixed journey-ad/live2d_src#1 and
journey-ad/live2d_src#3 , thanks for your great work!
xiazeyu added a commit to xiazeyu/live2d-widget.js that referenced this issue Aug 26, 2018
by the way, we fixed journey-ad/live2d_src#1 and
journey-ad/live2d_src#3 , thanks for your great work!
xiazeyu added a commit to xiazeyu/live2d-widget.js that referenced this issue Aug 26, 2018
by the way, we fixed journey-ad/live2d_src#1 and
journey-ad/live2d_src#3 , thanks for your great work!
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants