当前位置:网站首页>Popular cross domain
Popular cross domain
2022-06-25 15:41:00 【Bamboo shrimp】
Front end development front-end and back-end separation projects , You will often encounter cross domain (Cross-Origin) The problem of , Why is there a cross domain ? How to solve cross domain ? And what are the most common methods ?
what
The full name of cross domain is cross domain resource sharing
scene : When you request the interface address and the domain where the front-end file service is located ( Requested agreement ,ip And port ) At different times , You're going to report a mistake , Here's the picture
why
The cross domain problem is actually caused by the same origin strategy of the browser , The same origin policy is the protection mechanism of the browser , Only web pages are allowed to request services under the same domain name .
The requirements of the same origin strategy are 3 Same as : agreement , The domain name and port should be consistent
how
【 Configure the backend 】CORS
Whether the browser enables the cross domain protection mechanism will respond according to the backend configuration , So the server needs to make a cross domain configuration
How to configure :
Modify the response header of the interface :Access-Control-Allow-Origin, The value is *,, If the browser passes the judgment, it will allow cross domain
【 Configure intermediate server 】 Reverse proxy
It means to use a proxy server to send requests on behalf of the real server
【 Configure intermediate server 】 Forward agency
This means that a proxy server is used to send requests on behalf of clients , Generally, the browser is used as the proxy server , This is directly in webpack It's equipped with
JSONP【 Not recommended 】
Actually by script The characteristics of the label ( No cross domain restrictions ) To achieve cross domain , Server side cooperation is also required , And can only use get Method , There are security risks , Not recommended
边栏推荐
- Client development (electron) data store
- Why is it said that restarting can solve 90% of the problems
- Is it safe to open a stock account through the account opening link of the account manager?
- 剑指 Offer 03. 数组中重复的数字
- 0703 interface automation - MySQL database connection, encapsulation, adding database verification in use cases
- Is it safe to open a stock account in Guoxin golden sun?
- Super comprehensive custom deep copy function
- MySQL modifier l'instruction de champ
- Websocket (WS) cluster solution
- 合宙Air32F103CBT6开发板上手报告
猜你喜欢
Why is it said that restarting can solve 90% of the problems
Could not connect to redis at 127.0.0.1:6379 in Windows
[paper notes] semi supervised object detection (ssod)
Several common optimization methods
Afterword of Parl intensive learning 7-day punch in camp
Record the time to read the file (the system cannot find the specified path)
Day01: learning notes
剑指 Offer 10- I. 斐波那契数列
Globally unique key generation strategy - implementation principle of the sender
CV pre training model set
随机推荐
Generic - learning notes
Principle and implementation of MySQL master-slave replication (docker Implementation)
Paddlepaddle paper reproduction course biggan learning experience
[paper notes] contextual transformer networks for visual recognition
Pytorch distributed test pit summary
Work of the first week
Joseph Ring - formula method (recursive formula)
国信金太阳靠谱吗?是否合法?开股票账户安全吗?
Distributed transaction solution
(2) Relational database
How to debug grpc by postman
剑指 Offer 10- I. 斐波那契数列
Finally, we can figure out whether the binding event in the tag is bracketed or not
剑指 Offer 07. 重建二叉树
剑指 Offer II 091. 粉刷房子
Graphic control and layout basis of R visualization
Data preprocessing - normalization and standardization
Is Guoxin golden sun reliable? Is it legal? Is it safe to open a stock account?
什么是oa
If a thread overflows heap memory or stack memory, will other threads continue to work