当前位置:网站首页>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
边栏推荐
- Completabilefuture of asynchronous tools for concurrent programming
- Lombok common notes
- Programmer vs hacker thinking | daily anecdotes
- 异步处理容易出错的点
- 0706-- replace fields in the use case, such as mobile phone number or ID
- golang正则regexp包使用-05-扩展Expand()、根据正则切割Split()
- Image segmentation based on deep learning: network structure design
- Cloning and importing DOM nodes
- Sampling method and descriptive statistical function in R language
- MySQL performance optimization - index optimization
猜你喜欢

Summary of four parameter adjustment methods for machine learning

Differences and solutions of redis cache avalanche, cache penetration and cache breakdown
![[paper notes] contextual transformer networks for visual recognition](/img/e4/45185983e28664564bbf79023ccbf6.jpg)
[paper notes] contextual transformer networks for visual recognition

Several relationships of UML
Why is it said that restarting can solve 90% of the problems

golang使用mongo-driver操作——增(进阶)

剑指 Offer 09. 用两个栈实现队列

Asynchronous processing of error prone points

Day01: learning notes

Source code analysis of nine routing strategies for distributed task scheduling platform XXL job
随机推荐
JSON module dictionary and string conversion
Data preprocessing - normalization and standardization
Kali modify IP address
Netlogo learning
Cloning and importing DOM nodes
[paper notes] street view change detection with deconvolutional networks
Yolov4 coco pre train Darknet weight file
Using reentrantlock and synchronized to implement blocking queue
QT article outline
Sword finger offer 05 Replace spaces
[paper notes] rethinking and improving relative position encoding for vision transformer
MySQL transaction characteristics and implementation principle
JS的遍历和分支判断(2022年6月24日案例)
The last glory of the late Ming Dynasty - the battle of Korea
MySQL field truncation principle and source code analysis
Agent and classloader
Start using markdown
Architecture evolution of high-performance servers -- Suggestions
Leetcode122 timing of buying and selling stocks II
Summary of four parameter adjustment methods for machine learning