当前位置:网站首页>Configure cross domain requests
Configure cross domain requests
2022-06-30 01:58:00 【Wang Qiao SBB】
What is cross-domain
agreement , domain name 、 The same port is the same domain , Otherwise, it's all cross domain ,
The idea of configuration
- establish vue.congif.js file , Inside devServer It is used to configure the server of the development environment , There are proxy It is used to forward the proxy , stay proxy Inside target Set the forwarding URL
Cross domain forwarding
Because of cross domain problems ,axios Can't request URL data , But browsers can , So the application proxy forwards the request data to the web address we set , and axios Request URL , It is equivalent to a middleman acting as an agent
Code display
module.exports = {
devServer: {
// Server configuration of development environment
// Whether to automatically pop up the browser , Default false
open: false,
// Modify the default port , Default 8080
port: 9090,
proxy: {
// Forwarding by proxy
'/api': {
// Forwarded URL
target: "http://m.sirfang.com/api",
// Whether to start the local agent Default true
changeOrigin: true,
// Important points
pathRewrite: {
'^/api': ''
}
}
}
}
}
encapsulation api Changes after request
Need to change request Public URL settings in the request
const server = axios.create({
baseURL: '/api',
timeout: 6000
})
matters needing attention
- The file name cannot be changed
- You need to restart the project after configuration
Package project configuration
Purpose
- Improve packaging speed
- Reduce project volume , Increase the loading speed of the first screen
- Improve user experience
Extraction of common code
// Common code pull away
configureWebpack: config => {
//....
// Optimize item configuration
config.optimization = {
splitChunks: {
// Split code blocks
cacheGroups: {
vendor: {
// The third-party library is pulled away
chunks: 'all',
test: /node_modules/,
name: 'vendor',
minChunks: 1,// Before the split , The minimum number of times this code block should be referenced
maxInitialRequests: 5,
minSize: 0,// Greater than 0 Bytes
priority: 100// The weight
},
common: {
// Common module extraction
chunks: 'all',
test: /[\\/]src[\\/]js[\\/]/,
name: 'common',
minChunks: 2, // Before the split , The minimum number of times this code block should be referenced
maxInitialRequests: 5,
minSize: 0,// Greater than 0 Bytes
priority: 60
},
styles: {
// The pattern pulls away
name: 'styles',
test: /\.(sa|sc|c)ss$/,
chunks: 'all',
enforce: true
},
runtimeChunk: {
name: 'manifest'
}
}
}
}
}
边栏推荐
- MySQL monitoring 3
- 搞透AQS原理(流程圖及同步隊列圖解)
- 手势数字启蒙学习机
- [graph neural network] summary of graph classification study [3]: evaluation of graph classification methods and future research directions
- C语言 我要通过
- 工具与生活服务
- cookie加密8
- Chiffrement des cookies 8
- Application features and functions of painting Aquarium
- 【图神经网络】图分类学习研究综述[3]:图分类方法评价及未来研究方向
猜你喜欢

Comprendre le principe AQS (organigramme et schéma de file d'attente synchrone)
![[graph neural network] overview of graph classification learning [2]: graph classification based on graph neural network](/img/5f/b23b64eed7f28ffd92c122b6859e2d.png)
[graph neural network] overview of graph classification learning [2]: graph classification based on graph neural network

Cookie encryption 15 login encryption

C语言 成绩排名

【MySQL 05】SUSE 12 SP5 安装MySQL后第一次修改mysql密码

JS reverse request parameter encryption:

AI landing manufacturing: intelligent robots should have these four abilities
![【图神经网络】图分类学习研究综述[2]:基于图神经网络的图分类](/img/5f/b23b64eed7f28ffd92c122b6859e2d.png)
【图神经网络】图分类学习研究综述[2]:基于图神经网络的图分类

004_ icon

Unity2d-- add keys to animation and bind events
随机推荐
Geotools: common tools for mutual conversion of wkt, geojason, feature and featurecollection
004_ icon
A keepalived high availability accident made me learn it again!
Varnish foundation overview 10
C language score ranking
Geotools wkt coordinate system conversion
Matlab 2012a 绘制带箭头的线段
Database application
7 — filter
Is the processor the main factor in buying a mobile phone?
C language continues (3n+1) conjecture
Method of converting songs from DTS to MP3
OpenCV和Image之间的转换(亲测有效)
C语言 数组元素循环右移问题
想转行,但不知道自己要做什么工作比较好?
Varnish foundation overview 3
Cookie encryption 13
Three questions from the boss
(1) Basic learning - figure out the difference between pin, pad, port, IO and net
The national industrial information security development research center issued the report on industrial information security situation in 2021