当前位置:网站首页>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 .
边栏推荐
- AbstractDispatcherServletInitializer 的实现类为什么可以在初始化Web容器的时候被调用
- Besides, rsync+inotify realizes real-time backup of data
- Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
- Meituan Ali's Application Practice on multimodal recall
- Vit (vision transformer) principle and code elaboration
- 聊聊支付流程的设计与实现逻辑
- CANN算子:利用迭代器高效实现Tensor数据切割分块处理
- [leetcode] 96 and 95 (how to calculate all legal BST)
- 面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
- 数据库锁表?别慌,本文教你如何解决
猜你喜欢
Runc hang causes the kubernetes node notready
【Android Kotlin】lambda的返回语句和匿名函数
Reptile exercises (I)
Alibaba cloud award winning experience: build a highly available system with polardb-x
MDK在头文件中使用预编译器时,#ifdef 无效的问题
Fundamentals of container technology
光环效应——谁说头上有光的就算英雄
CA:用于移动端的高效坐标注意力机制 | CVPR 2021
CANN算子:利用迭代器高效实现Tensor数据切割分块处理
Concepts and theories related to distributed transactions
随机推荐
Reading cognitive Awakening
PostgreSQL 9.1 飞升之路
SQL语言
PostgreSQL 9.1 飞升之路
使用宝塔部署halo博客
Apache服务器访问日志access.log设置
8 expansion sub packages! Recbole launches 2.0!
Is there an elegant way to remove nulls while transforming a Collection using Guava?
SQL statement syntax error in test SQL statement deletion in eclipse linked database
How real-time cloud interaction helps the development of education industry
XILINX/system-controller-c/BoardUI/无法连接开发板,任意操作后卡死的解决办法
6 分钟看完 BGP 协议。
Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
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
Etcd storage, watch and expiration mechanism
Golang sets the small details of goproxy proxy proxy, which is applicable to go module download timeout and Alibaba cloud image go module download timeout
Xue Jing, director of insight technology solutions: Federal learning helps secure the flow of data elements
面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
Practice: fabric user certificate revocation operation process
使用 NSProxy 实现消息转发