Browse Source

添加devServer和部分配置

master
刘倡 4 months ago
parent
commit
77650ad077
  1. 2
      .env.development
  2. 3
      .env.production
  3. 20
      vue.config.js

2
.env.development

@ -0,0 +1,2 @@
# 开发环境配置
VUE_APP_API_URL = '/api'

3
.env.production

@ -0,0 +1,3 @@
# 生产环境配置
VUE_APP_API_URL = '/api'

20
vue.config.js

@ -0,0 +1,20 @@
module.exports = {
configureWebpack: {
resolve: {
alias: {
'@src': require('path').resolve(__dirname, 'src'), // 配置别名 '@src' 指向 'src' 目录
},
},
},
devServer: {
proxy: {
'/api': {
target: 'http://localhost:3000', // 后端 API 地址
changeOrigin: true, // 是否允许跨域
pathRewrite: {
'^/api': '', // 重写路径,将 '/api' 移除
},
},
},
},
};
Loading…
Cancel
Save