当前位置:网站首页>Vite configure proxy proxy to solve cross domain
Vite configure proxy proxy to solve cross domain
2022-04-23 17:46:00 【Suk_ A Shuo】
Code up :
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
// https://vitejs.dev/config/
export default defineConfig({
server: {
port: 9090,
strictPort: true, // Strict port true: If the port is already in use , You just quit , Instead of trying on subsequent ports .
/**
* @description solve chrome Set up origin:* Also cross domain mechanisms , agent /api Prefix to service base address
* The final address will be axios Set up baseUrl:/api The agent is spliced into [target][/api], And then through rewrite Rewrite it /api by '' This is our real base site
*/
proxy: {
'/api': {
target: 'http://www.baidu.com', // Interface address base
rewrite: path => {
console.log(path); // Print [/api/userInfo] This is it. http-proxy Requesting url, Our base address is actually not available /api therefore replace fall
return path.replace(/^\/api/, '');
}
}
}
},
plugins: [vue()],
resolve: {
alias: {
'@': resolve(__dirname, '.', 'src') // Set up @ Point to src
}
},
})
版权声明
本文为[Suk_ A Shuo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231741180609.html
边栏推荐
- 102. Sequence traversal of binary tree
- Indexes and views in MySQL
- 双闭环直流调速系统matlab/simulink仿真
- 92. 反转链表 II-字节跳动高频题
- uni-app黑马优购项目学习记录(下)
- MySQL advanced index [classification, performance analysis, use, design principles]
- Leak detection and vacancy filling (VII)
- 2021 Great Wall Cup WP
- Entity Framework core captures database changes
- Tell the truth of TS
猜你喜欢

2022制冷与空调设备运行操作判断题及答案
![MySQL advanced index [classification, performance analysis, use, design principles]](/img/96/b031868602a7b8ba4edd0d74c843b3.png)
MySQL advanced index [classification, performance analysis, use, design principles]

Hcip fifth experiment

How to change input into text

In JS, t, = > Analysis of

958. 二叉树的完全性检验

EasymodbusTCP之clientexample解析

flink 学习(十二)Allowed Lateness和 Side Output

SystemVerilog(六)-变量

440. 字典序的第K小数字(困难)-字典树-数节点-字节跳动高频题
随机推荐
Write a regular
[二叉数] 二叉树的最大深度+N叉树的最大深度
Advantages and disadvantages of several note taking software
Qt error: /usr/bin/ld: cannot find -lGL: No such file or directory
41. 缺失的第一个正数
索引:手把手教你索引从零基础到精通使用
MySQL installation
402. Remove K digits - greedy
[appium] write scripts by designing Keyword Driven files
How to manually implement the mechanism of triggering garbage collection in node
The system cannot be started after AHCI is enabled
SystemVerilog (VI) - variable
MySQL进阶学习之SQL优化【插入,主键,排序,分组,分页,计数】
386. 字典序排数(中等)-迭代-全排列
极致体验,揭晓抖音背后的音视频技术
油猴网站地址
JS interview question: FN call. call. call. Call (FN2) parsing
On the method of outputting the complete name of typeID from GCC
开源按键组件Multi_Button的使用,含测试工程
node中,如何手动实现触发垃圾回收机制