当前位置:网站首页>Don't turn down, three sentences to clarify the origin of cross domain resource request errors
Don't turn down, three sentences to clarify the origin of cross domain resource request errors
2022-07-04 13:19:00 【Boyue classmate】
Don't turn down , Three sentences to clarify the origin of cross domain resource request errors
Many students always encounter cross domain problems in their work , For example, such an error report
Access to XMLHttpRequest at ' 'http://test.com.cn/get' from origin 'http://local.com.cn:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
In fact, it is very simple to judge whether it is cross domain
Only agreement 、 domain name 、 Only when the ports are all the same can they be considered under the same domain , In other cases, there are cross domain !
The so-called agreement :https and http
The so-called domain name :test.com.cn and ai.test.com.cn It's different
So called port :80 Port and 8080 Ports are naturally different
Of course , Cross domain problems do not necessarily exist .
Because the cross domain problem is that the browser is for ajax A security restriction of a request : A page started ajax request , It can only be the path of the same domain name as the current page , This can effectively organize cross site attacks . in other words , The cross domain problem is aimed at ajax The limitation of , It's the browser's self-protection behavior .
Usually we use cors To solve the cross domain , You need to do some configuration for the back-end development students .
For simple and complex requests , There are two ways to deal with it . We will write an article on this tomorrow .
ps:CORS, yes HTML5 A feature of , It defines a way for browsers to interact with servers to determine whether cross domain requests are allowed .
You can add header information in the background to correspond to the front end , The permissions of the front-end sending request and the background control are compared with each other , So as to obtain the relevant permissions of the background , In this way, there is no cross domain problem .
边栏推荐
猜你喜欢
Comparative study of the gods in the twilight Era
实时云交互如何助力教育行业发展
分布式事务相关概念与理论
Reptile exercises (I)
游戏启动后提示安装HMS Core,点击取消,未再次提示安装HMS Core(初始化失败返回907135003)
ArcGIS uses grid processing tools for image clipping
Transformer principle and code elaboration (tensorflow)
Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
Read the BGP agreement in 6 minutes.
随机推荐
It is six orders of magnitude faster than the quantum chemical method. An adiabatic artificial neural network method based on adiabatic state can accelerate the simulation of dual nitrogen benzene der
游戏启动后提示安装HMS Core,点击取消,未再次提示安装HMS Core(初始化失败返回907135003)
Is the outdoor LED screen waterproof?
golang 设置goproxy代理的小细节,适用于go module下载超时,阿里云镜像go module下载超时
Efficient! Build FTP working environment with virtual users
阿里云有奖体验:用PolarDB-X搭建一个高可用系统
n++也不靠谱
ISO 27001 Information Security Management System Certification
When to use pointers in go?
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
6 分钟看完 BGP 协议。
高效!用虚拟用户搭建FTP工作环境
[leetcode] 96 and 95 (how to calculate all legal BST)
CANN算子:利用迭代器高效实现Tensor数据切割分块处理
N++ is not reliable
XILINX/system-controller-c/BoardUI/无法连接开发板,任意操作后卡死的解决办法
面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
[FAQ] summary of common causes and solutions of Huawei account service error 907135701
从0到1建设智能灰度数据体系:以vivo游戏中心为例
CVPR 2022 | transfusion: Lidar camera fusion for 3D target detection with transformer