增加Workerman代理转发配置
This commit is contained in:
1
.env
1
.env
@@ -21,6 +21,7 @@ VUE_APP_BASE_URL=http://127.0.0.1:22666/background/
|
||||
|
||||
# Workerman 接口地址和端口
|
||||
VUE_APP_WORKERMAN_URL=http://127.0.0.1:34351
|
||||
VUE_APP_WORKERMAN_API=/workerman
|
||||
|
||||
# 部署路径
|
||||
VUE_APP_PUBLIC_PATH=/dist/
|
||||
|
||||
@@ -9,3 +9,4 @@ VUE_APP_BASE_URL=http://127.0.0.1:22777/background/
|
||||
|
||||
# Workerman 接口地址和端口
|
||||
VUE_APP_WORKERMAN_URL=http://127.0.0.1:34351
|
||||
VUE_APP_WORKERMAN_API=/workerman
|
||||
|
||||
@@ -14,3 +14,4 @@ VUE_APP_PUBLIC_PATH=/
|
||||
|
||||
# Workerman 接口地址和端口
|
||||
VUE_APP_WORKERMAN_URL=http://127.0.0.1:34351
|
||||
VUE_APP_WORKERMAN_API=/workerman
|
||||
|
||||
@@ -2,6 +2,7 @@ import axios from 'axios'
|
||||
import { Message } from 'element-ui'
|
||||
|
||||
const WORKERMAN_URL = process.env.VUE_APP_WORKERMAN_URL || 'http://127.0.0.1:34351'
|
||||
const WORKERMAN_API = process.env.VUE_APP_WORKERMAN_API || WORKERMAN_URL
|
||||
|
||||
const workerman = axios.create({
|
||||
timeout: 10000,
|
||||
@@ -35,7 +36,7 @@ function buildRequestErrorMessage (error) {
|
||||
}
|
||||
|
||||
export function sendWorkerman (data) {
|
||||
return workerman.post(WORKERMAN_URL, normalizePayload(data)).then(response => {
|
||||
return workerman.post(WORKERMAN_API, normalizePayload(data)).then(response => {
|
||||
const result = response.data
|
||||
const businessError = readBusinessError(result)
|
||||
if (businessError) {
|
||||
|
||||
@@ -87,6 +87,13 @@ module.exports = {
|
||||
pathRewrite: {
|
||||
'^/background': ''
|
||||
}
|
||||
},
|
||||
'/workerman': {
|
||||
target: process.env.VUE_APP_WORKERMAN_URL,
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
'^/workerman': ''
|
||||
}
|
||||
}
|
||||
},
|
||||
disableHostCheck: process.env.NODE_ENV === 'development'
|
||||
|
||||
Reference in New Issue
Block a user