mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-09 01:47:20 +08:00
添加环境变量
This commit is contained in:
parent
a8ee79a443
commit
a111fcc574
2
.env.development
Normal file
2
.env.development
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 只在开发模式中被载入的环境变量
|
||||||
|
VUE_APP_PROXY_DOMAIN = http://127.0.0.1:3000
|
2
.env.production
Normal file
2
.env.production
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# 只在生产模式中被载入的环境变量
|
||||||
|
# VUE_APP_PROXY_DOMAIN= 服务地址
|
@ -13,6 +13,10 @@ const contextInfo: ContextProps = {
|
|||||||
dynamicText: "登录",
|
dynamicText: "登录",
|
||||||
}
|
}
|
||||||
export default {
|
export default {
|
||||||
|
mounted() {
|
||||||
|
// @ts-ignore
|
||||||
|
this.$http.request("get", "/getApi")
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
info,
|
info,
|
||||||
},
|
},
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
const dotEnv = require('dotenv')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
const VUE_APP_ENV = 'development'
|
||||||
|
const resolve = dir => path.join(__dirname, dir)
|
||||||
|
const { VUE_APP_PROXY_DOMAIN } = dotEnv.config({
|
||||||
|
path: resolve(`.env.${VUE_APP_ENV}`)
|
||||||
|
}).parsed
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
alias: {},
|
alias: {},
|
||||||
// 是否自动在浏览器打开
|
// 是否自动在浏览器打开
|
||||||
@ -18,7 +27,7 @@ module.exports = {
|
|||||||
// 反向代理
|
// 反向代理
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: 'http://127.0.0.1:3000',
|
target: VUE_APP_PROXY_DOMAIN,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: path => path.replace(/^\/api/, '')
|
rewrite: path => path.replace(/^\/api/, '')
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user