// vue.config.js
module.exports = {
devServer: {
proxy: {
'/api': {
target: 'http://localhost:4000', // 目标API服务器的基地址
changeOrigin: true, // 是否改变请求origin
pathRewrite: {
'^/api': '' // 重写路径,将 /api 前缀去掉
}
}
}
}
};
// 解释说明:
// 上述代码配置了 Vue CLI 的开发服务器 (devServer) 的代理设置。当请求以 "/api" 开头时,
// 它会被代理到目标服务器 "http://localhost:4000"。同时,通过 pathRewrite 将请求路径中的 "/api" 前缀去掉。
// 例如,客户端请求 "/api/users" 会被代理为 "http://localhost:4000/users"。
上一篇:vue3 .sync
下一篇:vue 生成uuid
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站