从跨域访问文件时,请遵循excepption [英] While accessing file from cross domain then arrive following excepption

查看:94
本文介绍了从跨域访问文件时,请遵循excepption的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin





我的尝试:



我必须尝试解决这个问题,如何访问



What I have tried:

what i have to try to solve this problem ,how can I access

推荐答案

你必须说服你的系统管理员让你做一些愚蠢和高度恶心的事情 - 建议。
You have to convince your system admin to let you do something stupid and highly ill-advised.


你必须说服远程站点的所有者在他们的站点上添加一个HTTP访问控制头,以允许你的站点从中加载资源:

HTTP访问控制(CORS) - HTTP | MDN [ ^ ]



如果他们不添加标题,那么您无法从该网站加载资源。这是一个安全限制,没有办法解决它。



您可以希望的最好的方法是在您的网站上添加代理脚本,来自您的服务器的请求,并将结果返回给浏览器。这将 NOT 可以访问用户的会话或cookie,因此您将无法代表用户执行任何经过身份验证的操作。
You have to convince the owners of the remote site to add an HTTP access control header to their site to allow your site to load resources from it:
HTTP access control (CORS) - HTTP | MDN[^]

If they won't add the header, then you can't load the resource from that site. This is a security restriction, and there is no way around it.

The best you can hope for is to add a "proxy" script on your site which makes the request from your server, and returns the result to the browser. This will NOT have access to the user's session or cookies, so you will not be able to perform any authenticated action on behalf of the user.


这篇关于从跨域访问文件时,请遵循excepption的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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