利用Nginx转发将CRAWLAB_API_ADDRESS设置为默认IP

This commit is contained in:
marvzhang
2020-01-12 19:28:34 +08:00
parent 4c95350c48
commit d8116630d3
8 changed files with 43 additions and 18 deletions

View File

@@ -2,7 +2,17 @@ import axios from 'axios'
import router from '../router'
import { Message } from 'element-ui'
// 根据 VUE_APP_BASE_URL 生成 baseUrl
let baseUrl = process.env.VUE_APP_BASE_URL ? process.env.VUE_APP_BASE_URL : 'http://localhost:8000'
if (!baseUrl.match(/^https?/i)) {
baseUrl = `http://${window.location.host}${process.env.VUE_APP_BASE_URL}`
}
// 如果 Docker 中设置了 CRAWLAB_API_ADDRESS 这个环境变量,则会将 baseUrl 覆盖
const CRAWLAB_API_ADDRESS = '###CRAWLAB_API_ADDRESS###'
if (!CRAWLAB_API_ADDRESS.match('CRAWLAB_API_ADDRESS')) {
baseUrl = CRAWLAB_API_ADDRESS
}
const request = (method, path, params, data, others = {}) => {
const url = baseUrl + path