当前位置:网站首页>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 .
边栏推荐
猜你喜欢

Practice: fabric user certificate revocation operation process

游戏启动后提示安装HMS Core,点击取消,未再次提示安装HMS Core(初始化失败返回907135003)

CVPR 2022 | transfusion: Lidar camera fusion for 3D target detection with transformer

Fundamentals of container technology

Understand bloomfilter in one article

CA:用于移动端的高效坐标注意力机制 | CVPR 2021

Transformer principle and code elaboration (pytorch)

Dry goods sorting! How about the development trend of ERP in the manufacturing industry? It's enough to read this article
Efficient! Build FTP working environment with virtual users

求解:在oracle中如何用一条语句用delete删除两个表中jack的信息
随机推荐
【云原生 | Kubernetes篇】深入了解Ingress(十二)
游戏启动后提示安装HMS Core,点击取消,未再次提示安装HMS Core(初始化失败返回907135003)
Vit (vision transformer) principle and code elaboration
Using nsproxy to forward messages
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
CTF竞赛题解之stm32逆向入门
CANN算子:利用迭代器高效实现Tensor数据切割分块处理
Go zero micro service practical series (IX. ultimate optimization of seckill performance)
C#/VB.NET 给PDF文档添加文本/图像水印
CVPR 2022 | TransFusion:用Transformer进行3D目标检测的激光雷达-相机融合
WPF双滑块控件以及强制捕获鼠标事件焦点
在 Apache 上配置 WebDAV 服务器
Sort merge sort
"Pre training weekly" issue 52: shielding visual pre training and goal-oriented dialogue
A taste of node JS (V), detailed explanation of express module
Runc hang causes the kubernetes node notready
8个扩展子包!RecBole推出2.0!
阿里云有奖体验:用PolarDB-X搭建一个高可用系统
After the game starts, you will be prompted to install HMS core. Click Cancel, and you will not be prompted to install HMS core again (initialization failure returns 907135003)