Access to XMLHttpRequest at 'file:///E:/projects/ThreejsSpace/fbxTest/Angry.fbx'
时间: 2024-04-25 14:18:50 浏览: 31
Access to XMLHttpRequest at 'file:///E:/projects/ThreejsSpace/fbxTest/Angry.fbx is a security feature implemented in web browsers to prevent cross-origin requests. It means that you are trying to make an XMLHttpRequest to a local file on your computer, which is not allowed due to security restrictions.
To access the file 'Angry.fbx' using XMLHttpRequest, you need to host it on a web server and access it through a valid URL. This can be done by setting up a local web server or uploading the file to a remote server.
相关问题
Access to XMLHttpRequest at 'file:///D:/vue/vue-first/data.json' from origin 'null' has been blocked by CORS policy
回答: 这个错误是由于浏览器的CORS策略引起的。CORS是一种安全机制,用于限制跨域请求。当浏览器发现请求的源与目标不在同一个域时,会发送一个预检请求,检查目标服务器是否允许跨域请求。如果目标服务器没有正确配置CORS头部,浏览器就会拒绝该请求,从而导致这个错误。\[1\]\[2\]
对于你提到的具体错误,'file:///D:/vue/vue-first/data.json'是一个本地文件路径,而'null'是请求的源。由于这是一个本地文件请求,而不是通过HTTP协议请求,所以CORS策略不适用于这种情况。因此,你可以通过将数据文件放在与你的应用程序相同的域中,或者使用服务器来提供数据,以避免这个错误。
#### 引用[.reference_title]
- *1* [Access to XMLHttpRequest at ‘http://xxx‘ from origin ‘http://xxx‘ has been blocked by CORS ...](https://blog.csdn.net/qq_41470439/article/details/109361842)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [前后端分离跨域问题Access to XMLHttpRequest at ‘http://localhos...has been blocked by CORS policy: ...](https://blog.csdn.net/qq_42416602/article/details/121731774)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Access to XMLHttpRequest at ‘http://xx‘ from origin ‘http://xx‘ has been blocked by CORS policy](https://blog.csdn.net/weixin_51603038/article/details/129319187)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
Access to XMLHttpRequest at 'http://39.98.175.93:9099/index/menu' from origi
Access to XMLHttpRequest at 'http://39.98.175.93:9099/index/menu' from origin 'http://example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
这个错误是由于浏览器的同源策略(Same-Origin Policy)所引起的。同源策略是浏览器的一种安全机制,限制了通过JavaScript发起的跨域请求。
在这个错误中,浏览器检测到你的代码正在尝试从一个源(origin)访问另一个源的资源。在默认情况下,浏览器阻止了这种跨域请求,除非服务器在响应中包含了适当的CORS头部。
为了解决这个问题,你需要在目标服务器上配置CORS头部,使其允许来自'http://example.com'的跨域请求。具体的配置方式和步骤取决于你使用的服务器和框架。
一种常见的解决方法是在服务器端设置响应头部,添加'Access-Control-Allow-Origin'字段,并将其值设为允许跨域请求的源的地址(例如'http://example.com')。这样浏览器就会允许来自该源的请求访问服务器资源了。
另外,你也可以使用代理服务器来绕过同源策略的限制。通过将跨域请求发送到代理服务器,再由代理服务器转发请求给目标服务器,这样就可以在不修改目标服务器配置的情况下实现跨域请求。
总结起来,要解决这个问题,你可以通过配置目标服务器的CORS头部,或者使用代理服务器来实现跨域请求。具体的实施方法和步骤会根据你的服务器和框架而有所不同。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)