fix: 修复vite热重启后proxy失效问题

This commit is contained in:
张传龙 2022-05-19 12:02:01 +08:00
parent 5bd380037c
commit 5ce2150706

View File

@ -16,7 +16,7 @@ export function wrapperEnv(envOptions) {
if (['VITE_PORT'].includes(key)) {
val = +val
}
if (key === 'VITE_PROXY' && val) {
if (key === 'VITE_PROXY' && val && typeof val === 'string') {
try {
val = JSON.parse(val.replace(/'/g, '"'))
} catch (error) {
@ -24,9 +24,9 @@ export function wrapperEnv(envOptions) {
}
}
ret[key] = val
if (typeof key === 'string') {
if (typeof val === 'string') {
process.env[key] = val
} else if (typeof key === 'object') {
} else if (typeof val === 'object') {
process.env[key] = JSON.stringify(val)
}
}