Vue:CORS问题。 Vue第二次加载图像,但带有“ no-cors” [英] Vue: CORS issue. Vue loads the image a second time but with "no-cors"

查看:346
本文介绍了Vue:CORS问题。 Vue第二次加载图像,但带有“ no-cors”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CORS的基本问题在我的

解决方案

似乎预检请求正在阻止来自其他域的资源



https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS


The underlying problem with CORS was solved in my previous question, however now I'm starting to test it in Vue and I still have CORS issues.

Please have a look at this code:

https://jsfiddle.net/xodk3h9u/

Note: If you are seeing the image in canvas correctly or the image unloaded, please cache+hardreload your browser to see the error or the image.

If you are clicking on the button and open your console, you will see that you are getting a CORS-error:

Access to image at 'https://local-spaces.fra1.digitaloceanspaces.com/test.jpg' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

The current issue is, that Vue is somehow loading two requests to the preloaded image. The first one with cors, the second one with no-cors. Later leads to the wrong caching of the image. Thus, clicking on the button leads to the error.

Why is Vue loading the image for a second round?

解决方案

seems preflight request is blocking resources, from other domain

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

这篇关于Vue:CORS问题。 Vue第二次加载图像,但带有“ no-cors”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆