当前位置:网站首页>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
边栏推荐
- Yolov4 coco pre train Darknet weight file
- If a thread overflows heap memory or stack memory, will other threads continue to work
- Go build reports an error missing go sum entry for module providing package ... to add:
- Why do I need message idempotence?
- 客户经理给的开户链接办理股票开户安全吗?我想开个户
- Go language modifies / removes multiple line breaks in strings
- Open the box to experience rust, come on!!!
- Pytest测试框架笔记
- Websocket (WS) cluster solution
- Principle and implementation of MySQL master-slave replication (docker Implementation)
猜你喜欢

剑指 Offer 07. 重建二叉树
Open the box to experience rust, come on!!!

For the first time in Chinese universities! Unique in the world! Tongji students win international awards

JVM memory region details

Several relationships of UML

Sword finger offer 06 Print linked list from end to end

How to download and install Weka package

Globally unique key generation strategy - implementation principle of the sender

Kali SSH Remote Login

Data preprocessing - normalization and standardization
随机推荐
Image segmentation based on deep learning: network structure design
Sword finger offer 06 Print linked list from end to end
[paper notes] rethinking and improving relative position encoding for vision transformer
[paper notes] mcunetv2: memory efficient patch based influence for tiny deep learning
For the first time in Chinese universities! Unique in the world! Tongji students win international awards
Is Guoxin golden sun reliable? Is it legal? Is it safe to open a stock account?
Is it safe to open a stock account in Guoxin golden sun?
Pytest测试框架笔记
Client development (electron) system level API usage 2
golang reverse a slice
Desktop development (Tauri) opens the first chapter
Statistical analysis - data level description of descriptive statistics
Es data synchronization mode
Sword finger offer 07 Rebuild binary tree
Is it safe to open a stock account through the account opening link given by the account manager? I want to open an account
(2) Relational database
QT source code online view
剑指 Offer 09. 用两个栈实现队列
Data preprocessing - normalization and standardization
双目3D感知(一):双目初步认识