当前位置:网站首页>Homology and cross domain
Homology and cross domain
2022-07-27 20:21:00 【Pig is not stupid】
One 、 The same-origin policy
1、 Same as Source (origin)
- Homology : If it's in the address agreement 、 Domain name and port number all identical It belongs to homology .
- The following is relative to http://www.a.com:8080/test/index.html Homology detection of :
http://www.a.com/dir/page.html ---- success (http Default port number bit 8080)
http://www.child.a.com/test/index.html ---- Failure , domain name Different
https://www.a.com/test/index.html ---- Failure , agreement Different
http://www.a.com:8089/test/index.html ---- Failure , Port number Different
2、 The same-origin policy
- Homology policy is a security function of browser , Client scripts from different sources are not explicitly authorized , Can't read and write to each other's resources . therefore a.com Under the js The script uses ajax Read b.com The file data in it will report an error .
- Not subject to the same origin policy :
① Links in the page , Redirection and form submission are not restricted by the same origin policy .
② Cross domain resources can be introduced . however js Can't read or write the loaded content . As embedded in the page <script src="..."></script>,<img>,<link>,<iframe> etc. .
Two 、 Cross domain
1. Cross domain :
as long as agreement 、 domain name 、 Port number There is a difference It's cross domain .
2. Cross domain reasons :
Cross domain problems arise from JavaScript The same origin strategy , That is, only agreement + Host name + Port number ( If it exists ) identical , Then mutual access is allowed . In order to prevent the interface under a domain name from being illegally called by web pages under other domain names , It 's the browser JavaScript Safety restrictions imposed . in other words JavaScript You can only access and operate resources under your own domain , Cannot access and operate resources under other domains . The cross domain problem is aimed at JS and ajax Of ,html There is no cross domain problem in itself , such as a label 、script label 、 even to the extent that form label ( You can send and receive data directly across domains ) etc. .
3、 ... and 、 Cross domain problem solution
1、jsonp
utilize script The tag can be cross domain , In the cross domain script, you can directly call back the function of the current script .
2、cors
server setting HTTP In the response header Access-Control-Allow-Origin value , Remove cross domain restrictions .
Be careful : Both cross domain solutions have a fatal flaw , Heavily dependent on back-end assistance .
3、 Reverse proxy (Reverse Proxy):
A cross domain solution that can be solved independently of the front end .
To accept as a proxy server internet Connection request on , Then forward the request to the server on the internal network , And return the results from the server to the internet Clients requesting connections on , At this time, the proxy server acts as a reverse proxy server .
边栏推荐
- YY English learning about fish
- 如何运行 kevinchappell / formBuilder
- 内置函数锁相关
- How to quickly improve the three minute response rate of Tiktok store? What will affect the reply rate of Tiktok store?
- Learn about the 12 necessary animation plug-ins of blender
- Program design Comprehensive Experiment III
- Built in function time date function
- Libpcap library and pcap_ Sendpacket interface function understanding
- Technology sharing | how to do Assertion Verification in interface automated testing?
- ES6 deleting attributes of objects_ ES6 delete an element "suggested collection" in the object
猜你喜欢
![[openbmc series] 4. Start the process and use qume to simulate ast2600 EVB](/img/ab/026111b25836758ec7ffec8d60f49d.png)
[openbmc series] 4. Start the process and use qume to simulate ast2600 EVB

站在巨人肩膀上学习,京东爆款架构师成长手册首发

PC Museum (3) MITs Altair 8800

产品经理:排查下线上哪里冒出个“系统异常”的错误提示

Technology sharing | how to do Assertion Verification in interface automated testing?

2022年,软件测试还能学吗?别学了,软件测试岗位饱和了...

Pyqt5 rapid development and practice 4.7 qspinbox (counter) and 4.8 QSlider (slider)

使用cpolar建立一个商业网站(5)

Add joint control to gltf model

PMP practice once a day | don't get lost in the exam -7.27 (including agility + multiple choices)
随机推荐
22 year PMP test [Quanzhen agile test]
ES6--解构赋值
ES6 deleting attributes of objects_ ES6 delete an element "suggested collection" in the object
JS 数组方法 forEach 和 map 比较
产品经理:排查下线上哪里冒出个“系统异常”的错误提示
汇顶科技:收购恩智浦VAS业务已完成交割
Function priority
[openbmc series] 4. Start the process and use qume to simulate ast2600 EVB
PyQt5快速开发与实战 4.5 按钮类控件 and 4.6 QComboBox(下拉列表框)
2019年全球半导体营收同比下滑12%,中国市场份额第一
How to quickly improve the three minute response rate of Tiktok store? What will affect the reply rate of Tiktok store?
set--数据解构
Solve the problem of displaying the scroll bar when there is no data in the viewui table
[map set]
预处理与宏定义
Technology sharing | how to do Assertion Verification in interface automated testing?
京东:按关键字搜索商品 API
JD: search product API by keyword
kubectl 获取pod日志 —— 筑梦之路
Konka semiconductor's first storage master chip was mass produced and shipped, with the first batch of 100000 chips