From 77650ad077498ece0dee14f36a2199071d9170cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=80=A1?= Date: Thu, 2 Jan 2025 10:04:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0devServer=E5=92=8C=E9=83=A8?= =?UTF-8?q?=E5=88=86=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 ++ .env.production | 3 +++ vue.config.js | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 .env.development create mode 100644 .env.production create mode 100644 vue.config.js diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..92d73b9 --- /dev/null +++ b/.env.development @@ -0,0 +1,2 @@ +# 开发环境配置 +VUE_APP_API_URL = '/api' diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..aa13e7f --- /dev/null +++ b/.env.production @@ -0,0 +1,3 @@ + +# 生产环境配置 +VUE_APP_API_URL = '/api' diff --git a/vue.config.js b/vue.config.js new file mode 100644 index 0000000..314f5af --- /dev/null +++ b/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' 移除 + }, + }, + }, + }, +};